⛄一、获取代码方式
获取代码方式1:
完整代码已上传我的资源:【数据聚类】基于matlab改进多元宇宙算法优化密度的噪声应用空间聚类MVO-DBSCAN数据聚类【含Matlab源码 7213期】
点击上面蓝色字体,直接付费下载,即可。
获取代码方式2:
付费专栏数据分析(Matlab)
备注:
点击上面蓝色字体付费专栏数据分析(Matlab),扫描上面二维码,付费299.9元订阅海神之光博客付费专栏,凭支付凭证,私信博主,可免费获得5份本博客上传CSDN资源代码(有效期为订阅日起,三天内有效);
点击CSDN资源下载链接:5份本博客上传CSDN资源代码
⛄二、部分源代码
clc
clear
close all
dataStorage = ‘Datasets’;
resultPath =‘results’;
if ~exist(resultPath,‘dir’)
mkdir(resultPath);
end
DataReposity = {‘artificial’};
Algorithms ={‘MVO-DBSCAN’,‘IMVO1-DBSCAN’,‘IMVO2-DBSCAN’,‘DBSCAN’};
MaxRun = 1;
for rep = 1:length(DataReposity)
rep
dataPath = [dataStorage,DataReposity{rep},‘’];
pathInfo = dir([dataPath,'*.txt']);
for ii = 1:length(pathInfo)
temp = strsplit(pathInfo(ii).name,'.');
dataNames{ii} = temp{1};
end
for i = 1:length(dataNames)
dataName = dataNames{i};
data = LoadDataset(dataPath,DataReposity{rep},dataName);
data.dataName = dataName;
for j = 1:length(Algorithms)
AlgName = Algorithms{j}
inits = initialization(DataReposity{rep},data,AlgName);
for run = 1:MaxRun
if strcmp(AlgName,'MVO-DBSCAN')
% execute clustering method on the problem
out = MVO_DBSCAN(inits.prob,inits.params);
clus = out.ptsC;
C = out.C;
Nc = out.Nc;
end
if strcmp(AlgName,'IMVO1-DBSCAN')
% execute clustering method on the problem
out = IMVO1_DBSCAN(inits.prob,inits.params);
clus = out.ptsC;
C = out.C;
Nc = out.Nc;
end
if strcmp(AlgName,'IMVO2-DBSCAN')
% execute clustering method on the problem
out = IMVO2_DBSCAN(inits.prob,inits.params);
clus = out.ptsC;
C = out.C;
Nc = out.Nc;
end
if strcmp(AlgName,'DBSCAN')
% execute clustering method on the problem
X = data.X; % points
[ptsC,C,Nc,Pvisit] = dbscan(X', inits.E, inits.minPts);
clus = ptsC;
end
%% save results
savePath = [resultPath,DataReposity{rep},'\',AlgName,'\'];
if ~exist(savePath,'dir')
mkdir(savePath);
end
if run == 1
if size(data.X,2) == 2
h = PlotClusteringResults(data.X,clus);
print(h,[savePath,dataName],'-djpeg','-r300')
close(h);
end
if strcmp(AlgName,'DBSCAN')
save([savePath,dataName,'_outs'],'clus','C','Nc');
else
GlobalBest = out.GlobalBest;
save([savePath,dataName,'_outs'],'clus','C','Nc','GlobalBest');
end
end
%% Evaluation
[results{i}.MeanAccuracy(run,j),results{i}.err(run,j)] = ...
ClusteringEvaluation1(clus,data.y);
[results{i}.F_measure(run,j)] = ClusteringEvaluation2(clus,data.y);
end
end
results{i}.dataName = dataName;
end
save([resultPath,DataReposity{rep},'\','results'],'results');
% bar plot
resultName = 'results';
barPlots([resultPath,DataReposity{rep},'\'],resultName,dataNames,Algorithms);
clear results dataNames
end
⛄三、运行结果
⛄四、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1] 由伟,刘亚秀.MATLAB数据分析教程[M].清华大学出版社,2020.
[2]王岩,隋思涟.试验设计与MATLAB数据分析[M].清华大学出版社,2012.
3 备注
简介此部分摘自互联网,仅供参考,若侵权,联系删除