cluster_optics_dbscan#

sklearn.cluster.cluster_optics_dbscan(*, reachability, core_distances, ordering, eps)#

执行DBSCAN提取以适应任意epsilon。

提取簇的操作在线性时间内运行。请注意,这将生成与使用类似设置和 eps 的:class:~sklearn.cluster.DBSCAN 接近的 labels_ ,前提是 eps 接近 max_eps

Parameters:
reachabilityndarray of shape (n_samples,)

由OPTICS计算的可及性距离( reachability_ )。

core_distancesndarray of shape (n_samples,)

点成为核心的距离( core_distances_ )。

orderingndarray of shape (n_samples,)

OPTICS排序点索引( ordering_ )。

epsfloat

DBSCAN的 eps 参数。必须设置为< max_eps 。如果 epsmax_eps 接近,结果将接近DBSCAN算法。

Returns:
labels_array of shape (n_samples,)

估计的标签。

Examples

>>> import numpy as np
>>> from sklearn.cluster import cluster_optics_dbscan, 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,
... )
>>> eps = 4.5
>>> labels = cluster_optics_dbscan(
...     reachability=reachability,
...     core_distances=core_distances,
...     ordering=ordering,
...     eps=eps,
... )
>>> labels
array([0, 0, 0, 1, 1, 1])