BUG? evalclusters is sensitive to rows (points) order

Dear All,
I have noticed that Silhouette Criterion evaluation (evalcluster) of clustering gives different results for different points order ! This does not make any sense in my opinion.
I guess row order in matrix should have no impact on criterion value.
clear; close all; clc;
N = 100;
D = 2;
klist = 1:25;
% original points
rng(1)
X = rand(N,D);
% shuffeled points order
rng(1)
X_sh = X(randperm(N), :);
%X_sh = X(sort(randperm(N)), :); % uncomment to control test
%% Silhoeutte test
for k = 1:length(klist)
%% no-shuffle
rng(1)
E = evalclusters(X, 'kmeans', 'silhouette', 'klist', klist(k), 'Distance', 'cosine');
%% shuffle
rng(1)
E_sh = evalclusters(X_sh, 'kmeans', 'silhouette', 'klist', klist(k), 'Distance', 'cosine');
Crit(k) = E.CriterionValues;
Crit_sh(k) = E_sh.CriterionValues;
end
clc
Crit
Crit_sh
%% (optional) Histogram to visualize
figure
bar(Crit, 'm')
hold on
bar(Crit_sh)
legend({'original' 'shuffled'}, 'Location', 'best'); title 'Silhouette criterion value'; xlabel 'Number of clusters'; xticks(klist); ylabel 'Value'; grid on;

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Genomics and Next Generation Sequencing 的更多信息

产品

版本

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by