本文整理匯總了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