compute_centroids

PLSCAN.compute_centroids(labels=None)

Return the probability-weighted centroid of each cluster.

For each cluster the centroid is the membership-probability-weighted mean of the feature vectors of all cluster members (noise points with label -1 are excluded). The result has shape (n_clusters, n_features).

Only available for feature-vector input (metric != "precomputed"). Raises ValueError for precomputed inputs and NotFittedError before fitting.

Parameters:

labels (ndarray[tuple[int], dtype[int_]] | None, default: None) – An optional integer array of shape (n_samples,) with cluster labels. When None (default), the fitted labels_ are used.

Return type:

ndarray[tuple[int, int], dtype[single]]

Returns:

centroids – Float32 array of shape (n_clusters, n_features).