本文整理匯總了Python中sklearn.cluster.optics_.OPTICS.filter方法的典型用法代碼示例。如果您正苦於以下問題:Python OPTICS.filter方法的具體用法?Python OPTICS.filter怎麽用?Python OPTICS.filter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sklearn.cluster.optics_.OPTICS
的用法示例。
在下文中一共展示了OPTICS.filter方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_filter
# 需要導入模塊: from sklearn.cluster.optics_ import OPTICS [as 別名]
# 或者: from sklearn.cluster.optics_.OPTICS import filter [as 別名]
def test_filter():
# Tests the filter function.
n_clusters = 3
X = generate_clustered_data(n_clusters=n_clusters)
# Parameters chosen specifically for this task.
clust = OPTICS(eps=6.0, min_samples=4, metric='euclidean')
# Run filter (before computing OPTICS)
bool_memb = clust.filter(X, 0.5)
idx_memb = clust.filter(X, 0.5, index_type='idx')
# Test for equivalence between 'idx' and 'bool' extraction
assert_equal(sum(bool_memb), len(idx_memb))
# Compute OPTICS
clust.fit(X)
clust.extract(0.5, clustering='dbscan')
# core points from filter and extract should be the same within 1 point,
# with extract occasionally underestimating due to start point of the
# OPTICS algorithm. Here we test for at least 95% similarity in
# classification of core/not core
agree = sum(clust._is_core == bool_memb)
assert_greater_equal(float(agree)/len(X), 0.95)