BUG? evalclusters is sensitive to rows (points) order

1 回表示 (過去 30 日間)
micholeodon
micholeodon 2019 年 3 月 7 日
編集済み: micholeodon 2019 年 3 月 11 日
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 件)

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by