【发布时间】:2015-06-07 11:15:06
【问题描述】:
得到一个预先计算的相似度矩阵Sim,其中s_ij 等于向量i 和向量j 之间的相似度。
尝试计算集群。 在做
clustering = SpectralClustering(cluster_count, affinity='precomputed', eigen_solver='arpack')
clustering.fit(sparse_dok_sim_matrix)
clusters = clustering.fit_predict(sparse_dok_sim_matrix)
print clusters
我得到的东西看起来像集群标签,但完全是错误的。同一簇中样本之间的边权重是图上边权重的 99%。聚类结果似乎完全随机且毫无意义。
任何建议,也许我做错了?
例如,我尝试使用 dbscan 进行此操作,但一无所获:
results = block_diag(np.ones((3,3)), np.ones((3,3)), np.ones((4,4)))
results = 1000 * (np.ones((len(results), len(results))) - results)
print results
print dbscan(X=results.astype(float), metric='precomputed')
这就是结果,它说一切都是噪音,尽管很明显前三点在同一个位置,接下来的三点也是如此……最后四点也是如此。
[[ 0. 0. 0. 1000. 1000. 1000. 1000. 1000. 1000. 1000.]
[ 0. 0. 0. 1000. 1000. 1000. 1000. 1000. 1000. 1000.]
[ 0. 0. 0. 1000. 1000. 1000. 1000. 1000. 1000. 1000.]
[ 1000. 1000. 1000. 0. 0. 0. 1000. 1000. 1000. 1000.]
[ 1000. 1000. 1000. 0. 0. 0. 1000. 1000. 1000. 1000.]
[ 1000. 1000. 1000. 0. 0. 0. 1000. 1000. 1000. 1000.]
[ 1000. 1000. 1000. 1000. 1000. 1000. 0. 0. 0. 0.]
[ 1000. 1000. 1000. 1000. 1000. 1000. 0. 0. 0. 0.]
[ 1000. 1000. 1000. 1000. 1000. 1000. 0. 0. 0. 0.]
[ 1000. 1000. 1000. 1000. 1000. 1000. 0. 0. 0. 0.]]
(array([], dtype=int64), array([-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]))
【问题讨论】:
标签: python-2.7 cluster-computing scikit-learn