evalclusters
statistics: eva = evalclusters (x, clust, criterion)
statistics: eva = evalclusters (…, Name, Value)
Create a clustering evaluation object to find the optimal number of clusters.
evalclusters creates a clustering evaluation object to evaluate the
optimal number of clusters for data x, using criterion criterion.
The input data x is a matrix with n observations of p
variables.
The evaluation criterion criterion is one of the following:
CalinskiHarabaszCalinskiHarabaszEvaluation object.DaviesBouldinDaviesBouldinEvaluation object.gapGapEvaluation object.silhouetteSilhouetteEvaluation object.The clustering algorithm clust is one of the following:
kmeanskmeans with EmptyAction set to
singleton and Replicates set to 5.linkageclusterdata with linkage set to
Ward.gmdistributionfitgmdist with SharedCov set to
true and Replicates set to 5. If the criterion is CalinskiHarabasz, DaviesBouldin, or
silhouette, clust can also be a function handle to a function
of the form c = clust(x, k), where x is the input data,
k the number of clusters to evaluate and c the clustering result.
The clustering result can be either an array of size n with k
different integer values, or a matrix of size n by k with a
likelihood value assigned to each one of the n observations for each
one of the k clusters. In the latter case, each observation is assigned
to the cluster with the higher value. If the criterion is
CalinskiHarabasz, DaviesBouldin, or
silhouette, clust can also be a matrix of size n by
k, where k is the number of proposed clustering solutions, so
that each column of clust is a clustering solution.
In addition to the obligatory x, clust and criterion inputs
there is a number of optional arguments, specified as pairs of Name
and Value options. The known Name arguments are:
KListDistancesilhouette, it can be a vector as created by
function pdist. Valid distance metric strings are: sqEuclidean
(default), Euclidean, cityblock, cosine,
correlation, Hamming, Jaccard.
Only used by silhouette and gap evaluation.ClusterPriorsempirical
(default), or equal. When empirical the silhouette value is
the average of the silhouette values of all points; when equal the
silhouette value is the average of the average silhouette value of each
cluster. Only used by silhouette evaluation.Bgap evaluation.ReferenceDistributionPCA (default) for a distribution based on the principal components of
X, or uniform for a uniform distribution based on the range of
the observed data. PCA is currently not implemented.
Only used by gap evaluation.SearchMethodgap evaluation. It
can be either globalMaxSE (default) for selecting the smallest number
of clusters which is inside the standard error of the maximum gap value, or
firstMaxSE for selecting the first number of clusters which is inside
the standard error of the following cluster number.
Only used by gap evaluation.Output eva is a clustering evaluation object.
See also: CalinskiHarabaszEvaluation, DaviesBouldinEvaluation, GapEvaluation, SilhouetteEvaluation
Source Code: evalclusters
load fisheriris; eva = evalclusters (meas, 'kmeans', 'calinskiharabasz', 'KList', [1:6])
eva =
1x1 CalinskiHarabaszEvaluation object with properties:
ClusteringFunction: 'kmeans'
CriterionName: 'CalinskiHarabasz'
CriterionValues: [NaN, 513.92, 561.63, 529.20, 495.54, 470.45]
InspectedK: [1, 2, 3, 4, 5, 6]
Missing: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...]
NumObservations: 150
OptimalK: 3
OptimalY: [2; 2; 2; 2; 2; 2; 2; 2; 2; 2; ...]
X: [5.1000, 3.5000, 1.4000, 0.2000; 4.9000, 3, 1.4000, 0.2000; 4.7000, 3.2000, ...]
plot (eva)
ans = -188.88