compute_medoid_indices¶
- PLSCAN.compute_medoid_indices(labels=None)¶
Return the index of the medoid point for each cluster.
For each cluster the medoid is the cluster member whose probability-weighted sum of pairwise within-cluster distances is smallest — the point
i*in clustercthat minimises:\[i^* = \operatorname{arg\,min}_{i \in c} \sum_{j \in c} p_j \cdot d(x_i, x_j)\]where \(p_j\) is the cluster-membership probability of point \(j\) and \(d\) is the fitted distance metric.
For feature-vector inputs, exact pairwise distances are used. For precomputed sparse distance inputs, the average mutual reachability distances are used to compensate for variations in the sparsity of the input graph.
Returns one index per cluster into the original input, making it simple to retrieve any attribute of the medoid point.
Only available for feature-vector or (sparse) precomputed distance inputs. Raises
ValueErrorfor precomputed MST inputs andNotFittedErrorbefore fitting.- Parameters:
labels (
ndarray[tuple[int],dtype[int_]] |None, default:None) – An optional integer array of shape(n_samples,)with cluster labels. WhenNone(default), the fittedlabels_are used.- Return type:
- Returns:
medoid_indices – Integer array of shape
(n_clusters,)with the index of the medoid point for each cluster.