membership_vectors

fast_plscan.prediction.membership_vectors(clusterer, X, labels=None)

Approximate soft cluster membership vectors for unseen points.

This adapts HDBSCAN-style prediction to PLSCAN in distance space. Each new point is attached through its nearest mutual-reachability training neighbor, then blended distance and topology weights are scaled by the probability of belonging to any selected cluster.

Parameters:
  • clusterer (PLSCAN) – A fitted PLSCAN estimator trained on feature-vector input.

  • X (ndarray[tuple[int, int], dtype[single]]) – New feature vectors with shape (n_samples_new, n_features).

  • labels (ndarray[tuple[int], dtype[int_]] | None, default: None) – Optional cluster labels of shape (n_samples,) used to define the selected clusters and exemplars on the fitted data. When None (default), fitted labels_ are used.

Return type:

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

Returns:

membership_vectors – Float32 array of shape (n_samples_new, n_clusters). Entry [i, c] is the approximate soft membership of unseen point i in cluster c. Row sums are less than or equal to 1.

Raises:
  • NotFittedError – If clusterer has not been fitted.

  • ValueError – If clusterer was fitted with precomputed input, or if X has an invalid number of features.

  • ValueError – If the shape of labels does not match the fitted number of samples.