cluster_optics_xi#

sklearn.cluster.cluster_optics_xi(*, reachability, predecessor, ordering, min_samples, min_cluster_size=None, xi=0.05, predecessor_correction=True)[源代码]#

根据Xi-steep方法自动提取集群。

参数:
reachability形状的nd数组(n_samples,)

OPTICS计算的可达距离 (reachability_ ).

predecessor形状的nd数组(n_samples,)

前身由OPTICS计算。

ordering形状的nd数组(n_samples,)

OPTICS有序点指数 (ordering_ ).

min_samplesint > 1或在0和1之间浮动

与给予OPTICS的min_samples相同。上下陡峭的地区不能有更多 min_samples 连续的非陡点。以绝对数字或样本数量的一小部分表示(四舍五入至少为2)。

min_cluster_sizeint > 1或在0和1之间浮动,默认=无

OPTICS集群中的最小样本数,表示为绝对数或样本数的一小部分(四舍五入至少为2)。如果 None ,的价值 min_samples 而是使用。

xi浮动在0和1之间,默认=0.05

确定构成集群边界的可达性图上的最小陡度。例如,可达性图中的向上点由一个点与其后继点的比率最多为1-xi来定义。

predecessor_correction布尔,默认=True

根据计算出的前辈正确的集群。

返回:
labels形状的nd数组(n_samples,)

分配给样本的标签。未包含在任何集群中的点标记为-1。

clusters形状的nd数组(n_clusters,2)

形式的集群列表 [start, end] 在每一行中,包括所有索引。集群的排序根据 (end, -start) (上升),以便包含较小集群的较大集群紧随这些嵌套的较小集群之后。以来 labels 通常不反映等级制度 len(clusters) > np.unique(labels) .

示例

>>> import numpy as np
>>> from sklearn.cluster import cluster_optics_xi, compute_optics_graph
>>> X = np.array([[1, 2], [2, 5], [3, 6],
...               [8, 7], [8, 8], [7, 3]])
>>> ordering, core_distances, reachability, predecessor = compute_optics_graph(
...     X,
...     min_samples=2,
...     max_eps=np.inf,
...     metric="minkowski",
...     p=2,
...     metric_params=None,
...     algorithm="auto",
...     leaf_size=30,
...     n_jobs=None
... )
>>> min_samples = 2
>>> labels, clusters = cluster_optics_xi(
...     reachability=reachability,
...     predecessor=predecessor,
...     ordering=ordering,
...     min_samples=min_samples,
... )
>>> labels
array([0, 0, 0, 1, 1, 1])
>>> clusters
array([[0, 2],
       [3, 5],
       [0, 5]])