✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。
🍎个人主页:Matlab科研工作室
🍊个人信条:格物致知。
更多Matlab仿真内容点击👇
⛄ 内容介绍
制冷系统故障可由多种模型进行模拟诊断.为了提高其诊断性能,将包括K近邻模型(KNN),支持向量机(SVM),决策树模型(DT),随机森林模型(RF)及逻辑斯谛回归模型(LR)在内的5种成员诊断器,通过绝对多数投票方法集成为一个集成模型,并采用美国采暖,制冷与空调工程师学会(ASHRAE)故障数据对1台90冷吨的离心式冷水机组进行建模及验证,数据包含制冷系统的7类典型故障及一类正常运行.结果表明:集成模型在所选数据集上总体诊断正确率达到99.58%,较各成员诊断器(94.55%~99.05%)均有显著提升,对正常运行,局部故障及全局故障的诊断性能亦有改善.此外,对比分析了不同集成模型及成员诊断器的诊断性能,从中找到诊断正确率与时间成本最佳的集成模型(99.41%,1.34 s).可见,集成模型较单一模型性能更佳,在制冷系统故障诊断中具有更好的应用前景.
⛄ 部分代码
% Gaussian Mixture Model (10/12/2020)
function GMM = mGaussianMixtureModel(feat,label,opts)
% Default
kfold = 10;
tf = 2;
if isfield(opts,'kfold'), kfold = opts.kfold; end
if isfield(opts,'ho'), ho = opts.ho; end
if isfield(opts,'tf'), tf = opts.tf; end
% Number of class
num_class = numel(unique(label));
% [Hold-out]
if tf == 1
fold = cvpartition(label,'HoldOut',ho);
% Call train & test data
xtrain = feat(fold.training,:); ytrain = label(fold.training);
xtest = feat(fold.test,:); ytest2 = label(fold.test);
% Train model
My_Model = fitgmdist(xtrain,num_class,...
'Options',statset('MaxIter',1000),...
'Regularize',1e-5,...
'Start',ytrain);
% Test using cluster
pred2 = cluster(My_Model,xtest);
% Accuracy
Afold = sum(pred2 == ytest2) / length(ytest2);
% [Cross-validation]
elseif tf == 2
fold = cvpartition(label,'KFold',kfold);
Afold = zeros(kfold,1);
pred2 = [];
ytest2 = [];
for i = 1:kfold
% Call train & test data
trainIdx = fold.training(i); testIdx = fold.test(i);
xtrain = feat(trainIdx,:); ytrain = label(trainIdx);
xtest = feat(testIdx,:); ytest = label(testIdx);
% Train model
My_Model = fitgmdist(xtrain,num_class,...
'Options',statset('MaxIter',1000),...
'Regularize',1e-5,...
'Start',ytrain);
% Test using cluster
pred = cluster(My_Model,xtest);
% Accuracy
Afold(i) = sum(pred == ytest) / length(ytest);
% Store temporary
pred2 = [pred2(1:end); pred];
ytest2 = [ytest2(1:end); ytest];
end
% [Leave-one out]
elseif tf == 3
fold = cvpartition(label,'LeaveOut');
% Size of data
num_data = length(label);
Afold = zeros(num_data,1);
pred2 = [];
ytest2 = [];
for i = 1:num_data
% Call train & test data
trainIdx = fold.training(i); testIdx = fold.test(i);
xtrain = feat(trainIdx,:); ytrain = label(trainIdx);
xtest = feat(testIdx,:); ytest = label(testIdx);
% Train model
My_Model = fitgmdist(xtrain,num_class,...
'Options',statset('MaxIter',1000),...
'Regularize',1e-5,...
'Start',ytrain);
% Test using cluster
pred = cluster(My_Model,xtest);
% Accuracy
Afold(i) = sum(pred == ytest) / length(ytest);
% Store temporary
pred2 = [pred2(1:end); pred];
ytest2 = [ytest2(1:end); ytest];
end
end
% Confusion matrix
confmat = confusionmat(ytest2,pred2);
% Overall accuracy
acc = mean(Afold);
% Store result
GMM.acc = acc;
GMM.con = confmat;
if tf == 1
fprintf('\n Accuracy (GMM-HO): %g %%',100 * acc);
elseif tf == 2
fprintf('\n Accuracy (GMM-CV): %g %%',100 * acc);
elseif tf == 3
fprintf('\n Accuracy (GMM-LOO): %g %%',100 * acc);
end
end
⛄ 运行结果
⛄ 参考文献
Katırcıoğlu F, Cingiz Z. Fault diagnosis for overcharge and undercharge conditions in refrigeration systems using infrared thermal images. Proceedings of the Institution of Mechanical Engineers, Part E: Journal of Process Mechanical Engineering. 2023;0(0). doi:10.1177/09544089221148065
⛳️ 代码获取关注我
❤️部分理论引用网络文献,若有侵权联系博主删除
❤️ 关注我领取海量matlab电子书和数学建模资料