RuleTree.evaluation.evaluate_clustering_internal#
- evaluate_clustering_internal(X, labels, metric='euclidean') dict[source]#
Quality of a clustering from the data alone (internal metrics).
- Parameters:
X (array-like of shape (n_samples, n_features), or (n_samples, n_samples) if metric='precomputed') – Numerical data, or the matrix of the distances between the instances.
labels (array-like of shape (n_samples,)) – Cluster labels.
metric (str or callable, default='euclidean') – Distance used by the silhouette, as in
sklearn.metrics.silhouette_score; ‘precomputed’ if X is a distance matrix (then only the silhouette is computed).
- Returns:
scores –
silhouette_score(the higher the better),calinski_harabasz(the higher the better) anddavies_bouldin(the lower the better); nan with a single cluster.- Return type:
See also
evaluate_clusteringmetrics that compare the clusters with known classes.
Examples
>>> from sklearn.datasets import make_blobs >>> from RuleTree import RuleTreeCluster >>> from RuleTree.evaluation import evaluate_clustering_internal >>> X, _ = make_blobs(n_samples=300, centers=3, cluster_std=0.5, random_state=0) >>> labels = RuleTreeCluster(max_depth=3, random_state=0).fit_predict(X) >>> round(evaluate_clustering_internal(X, labels)["silhouette_score"], 2) 0.59