Learn R Programming

rtemis (version 1.4.3)

clustering_metrics: Clustering Metrics

Description

Quantify a fitted clustering on the data it was fitted on: how many cases and clusters, the fraction labeled noise, how concentrated the memberships of a soft clustering are, and how well separated its clusters are.

Usage

clustering_metrics(clust, x, verbosity = 1L)

Value

ClusteringMetrics object.

Arguments

clust

Clustering object.

x

Tabular data (data.frame, data.table, or tibble): The data clust was fitted on.

verbosity

Integer: Verbosity level.

Author

EDG

Details

cluster() stores the measures that cost no more than one pass over the assignments on its result, where get_metrics() returns them, and reports the mean silhouette as not requested. This function computes the same measures and the mean silhouette, whose cost is quadratic in the number of cases. The silhouette uses Euclidean distances over the clustered features, clust@config@features, and excludes cases labeled noise (label 0).

Each measure carries a status: computed, unsupported (the clustering does not have what the measure needs, such as a membership matrix), or not_applicable (the silhouette when fewer than two clusters hold a case).

x must be the data clust was fitted on, with one row per case, since the measures pair each row with its fitted assignment. Data whose fingerprint differs from the one cluster() recorded raises an error.

Examples

Run this code
if (FALSE) { # requireNamespace("flexclust", quietly = TRUE)
x <- exc(iris, "Species")
iris_km <- cluster(x, algorithm = "KMeans", verbosity = 0L)
clustering_metrics(iris_km, x, verbosity = 0L)
}

Run the code above in your browser using DataLab