本文整理汇总了Python中sklearn.cluster.optics_.OPTICS.extract_dbscan方法的典型用法代码示例。如果您正苦于以下问题:Python OPTICS.extract_dbscan方法的具体用法?Python OPTICS.extract_dbscan怎么用?Python OPTICS.extract_dbscan使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.cluster.optics_.OPTICS
的用法示例。
在下文中一共展示了OPTICS.extract_dbscan方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_dbscan_optics_parity
# 需要导入模块: from sklearn.cluster.optics_ import OPTICS [as 别名]
# 或者: from sklearn.cluster.optics_.OPTICS import extract_dbscan [as 别名]
def test_dbscan_optics_parity(eps, min_samples):
# Test that OPTICS clustering labels are <= 5% difference of DBSCAN
centers = [[1, 1], [-1, -1], [1, -1]]
X, labels_true = make_blobs(n_samples=750, centers=centers,
cluster_std=0.4, random_state=0)
# calculate optics with dbscan extract at 0.3 epsilon
op = OPTICS(min_samples=min_samples).fit(X)
core_optics, labels_optics = op.extract_dbscan(eps)
# calculate dbscan labels
db = DBSCAN(eps=eps, min_samples=min_samples).fit(X)
contingency = contingency_matrix(db.labels_, labels_optics)
agree = min(np.sum(np.max(contingency, axis=0)),
np.sum(np.max(contingency, axis=1)))
disagree = X.shape[0] - agree
# verify core_labels match
assert_array_equal(core_optics, db.core_sample_indices_)
non_core_count = len(labels_optics) - len(core_optics)
percent_mismatch = np.round((disagree - 1) / non_core_count, 2)
# verify label mismatch is <= 5% labels
assert percent_mismatch <= 0.05