Toggle Menu
Prev Up Next

scikit-learn 1.3.2
Other versions

Please cite us if you use the software.

# `sklearn.cluster`.cluster_optics_xi

sklearn.cluster.cluster_optics_xi(*, reachability, predecessor, ordering, min_samples, min_cluster_size=None, xi=0.05, predecessor_correction=True)

  Automatically extract clusters according to the Xi-steep method.

  Parameters:
    reachability ndarray of shape (n_samples,)

      Reachability distances calculated by OPTICS (`reachability_`).

    predecessor ndarray of shape (n_samples,)

      Predecessors calculated by OPTICS.

    ordering ndarray of shape (n_samples,)

      OPTICS ordered point indices (`ordering_`).

    min_samples int > 1 or float between 0 and 1

      The same as the min_samples given to OPTICS. Up and down steep regions can’t have more then `min_samples` consecutive non-steep points. Expressed as an absolute number or a fraction of the number of samples (rounded to be at least 2).

    min_cluster_size int > 1 or float between 0 and 1, default=None

      Minimum number of samples in an OPTICS cluster, expressed as an absolute number or a fraction of the number of samples (rounded to be at least 2). If `None`, the value of `min_samples` is used instead.

    xi float between 0 and 1, default=0.05

      Determines the minimum steepness on the reachability plot that constitutes a cluster boundary. For example, an upwards point in the reachability plot is defined by the ratio from one point to its successor being at most 1-xi.

    predecessor_correction bool, default=True

      Correct clusters based on the calculated predecessors.

  Returns:
    labels ndarray of shape (n_samples,)

      The labels assigned to samples. Points which are not included in any cluster are labeled as -1.

    clusters ndarray of shape (n_clusters, 2)

      The list of clusters in the form of `[start, end]` in each row, with all indices inclusive. The clusters are ordered according to `(end, -start)` (ascending) so that larger clusters encompassing smaller clusters come after such nested smaller clusters. Since `labels` does not reflect the hierarchy, usually `len(clusters) > np.unique(labels)`.