【发布时间】:2017-10-02 18:03:33
【问题描述】:
我正在尝试使用 K-means 方法进行聚类,但我想衡量我的聚类的性能。 我不是专家,但我渴望了解有关集群的更多信息。
这是我的代码:
import pandas as pd
from sklearn import datasets
#loading the dataset
iris = datasets.load_iris()
df = pd.DataFrame(iris.data)
#K-Means
from sklearn import cluster
k_means = cluster.KMeans(n_clusters=3)
k_means.fit(df) #K-means training
y_pred = k_means.predict(df)
#We store the K-means results in a dataframe
pred = pd.DataFrame(y_pred)
pred.columns = ['Species']
#we merge this dataframe with df
prediction = pd.concat([df,pred], axis = 1)
#We store the clusters
clus0 = prediction.loc[prediction.Species == 0]
clus1 = prediction.loc[prediction.Species == 1]
clus2 = prediction.loc[prediction.Species == 2]
k_list = [clus0.values, clus1.values,clus2.values]
现在我已经存储了我的 KMeans 和三个集群,我正在尝试使用 Dunn Index 来衡量我的集群性能(我们寻求更大的索引) 为此,我导入了 jqm_cvi 包(可用here)
from jqmcvi import base
base.dunn(k_list)
我的问题是:Scikit Learn 中是否已经存在任何聚类内部评估(来自剪影分数的除外)?还是在另一个知名图书馆?
感谢您的宝贵时间
【问题讨论】:
-
您可以在此处找到概述:scikit-learn.org/stable/modules/clustering.html(2.3.9. 集群性能评估)
-
以上链接中的大多数性能算法都依赖于“基本事实”标签。 Scikit Learn 上唯一可用的内部评估算法是 silhouette_score 和 Calinski-Harabaz 指数,对吧?
-
scikit-learn.org/stable/modules/…中给出了很多性能评估策略
标签: python machine-learning scikit-learn cluster-analysis sklearn-pandas