cluster_optics_dbscan#
- sklearn.cluster.cluster_optics_dbscan(*, reachability, core_distances, ordering, eps)[source]#
对任意epsilon执行DBSCAN提取。
提取集群运行时间为线性时间。请注意,这会导致
labels_
接近具有相似设置和eps
的DBSCAN
,只有当eps
接近max_eps
时才如此。- 参数:
- 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
。如果eps
和max_eps
彼此接近,则结果将接近 DBSCAN 算法。
- 返回值:
- labels_形状为 (n_samples,) 的数组
估计的标签。
示例
>>> 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])
图库示例#
OPTICS 聚类算法演示