-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcfo.m
37 lines (35 loc) · 1.6 KB
/
cfo.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function [predict_labels, U]=cfo(dataset, number_of_clusters,algorithm,seed)
U = [];
switch algorithm
case 'kmeans'
% [predict_labels,~] = kmeans(dataset,number_of_clusters);
[theta]=rand_data_init(dataset',number_of_clusters,seed);
[~,predict_labels,~]=k_means(dataset',theta);
case 'fuzzy'
options = [2.0 NaN NaN 0];
[theta,U] = fcm(dataset,number_of_clusters, options);
predict_labels = plot_fuzzy(number_of_clusters,theta,U,dataset);
case 'possibilistic'
% for q=1.5:1.0:2.5
q = 1.7;
eta = find_eta(dataset,number_of_clusters,q);
[U,predict_labels]=possibi(dataset',number_of_clusters,eta,q,23,3,0.01);
% tlt = "Possibilistic Clustering (q = " + q + ")";
% plot_possibilistic(number_of_clusters,predict_labels',dataset,tlt)
predict_labels = plot_fuzzy(number_of_clusters,predict_labels',U',dataset);
% view_image(predict_labels);
% end
case 'probabilistic'
[theta]=rand_data_init(dataset',number_of_clusters,0);
v = ones(3,1);
D = diag(v);
for i=1:number_of_clusters
cov(:,:,i) = D;
end
[~,cp,mv,~,~,~]=GMDAS(dataset',theta,cov,0.000001,1000,0);
% plot_probabilistic(dataset, mv')
predict_labels = plot_fuzzy(number_of_clusters,mv',cp',dataset);
otherwise
disp('Error: There is no CFO algorithm with this name')
end
end