本文整理汇总了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)