BUG? evalclusters is sensitive to rows (points) order

1 Ansicht (letzte 30 Tage)
micholeodon
micholeodon am 7 Mär. 2019
Bearbeitet: micholeodon am 11 Mär. 2019
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;

Antworten (0)

Produkte


Version

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by