本文整理汇总了Python中sklearn.cluster.KMeans.plot_k_sse方法的典型用法代码示例。如果您正苦于以下问题:Python KMeans.plot_k_sse方法的具体用法?Python KMeans.plot_k_sse怎么用?Python KMeans.plot_k_sse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.cluster.KMeans
的用法示例。
在下文中一共展示了KMeans.plot_k_sse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dendrogram
# 需要导入模块: from sklearn.cluster import KMeans [as 别名]
# 或者: from sklearn.cluster.KMeans import plot_k_sse [as 别名]
dendrogram(links)
knn(meta[liwc].T, labels=liwc)
knn(meta[liwc], labels=meta['Name of Work'].values)
'''K-means'''
k = KMeans(n_clusters=5) # 5 is at an elbow for sse in 2-d
km = k.fit_transform(truncatedFeatures)
'''PCA'''
pca, X_pca, k, km = kcluster(justDFeatures, n_clusters=8)
print features.columns[np.argsort(pca.components_[0])[:100]]
# plt.savefig("scree.png", dpi= 100)
pca = decomposition.PCA(n_components=2)
X_pca = pca.fit_transform(X_centered)
plot_embedding(X_pca, y)
k.plot_k_sse(X_pca) # for 2 components 5 clusters
''' Supervised Learning'''
# Logistic Regression and Random Forest seem to perform the best
# Nonfiction seems unpredictable, while fiction, letters and poetry
# are somewhat predictabe
for genre in set(meta.Genre):
df = meta[meta.Genre == genre].reset_index()
if len(df) > 20:
y = df.pop('deprivation')
print genre, 'Logit'
p.plot_roc(df[liwc].fillna(0), y, LogisticRegression)
print genre, 'Random Forest'
p.plot_roc(df[liwc].fillna(0), y, RandomForestClassifier)