-2
このコードは、各クラスタのインデックスとソートのためのもので、クラスタ重心に最も近いn個(n = 6を選択)の単語を識別します。 とにかく、この種のエラーが見つかりました: 'float'オブジェクトに 'エンコード'属性がありません'float'オブジェクトには 'エンコード'属性がありません
誰でも助けてくれますか? コードは以下の通りです:
from __future__ import print_function
print("Top terms per cluster:")
print()
#sort cluster centers by proximity to centroid
order_centroids = km.cluster_centers_.argsort()[:, ::-1]
for i in range(num_clusters):
print("Cluster %d words:" % i, end='')
for ind in order_centroids[i, :6]: #replace 6 with n words per cluster
print(' %s' % vocab_frame.ix[terms[ind].split(' ')].values.tolist()[0][0].encode('utf-8', 'ignore'), end=',')
print() #add whitespace
print() #add whitespace
print("Cluster %d titles:" % i, end='')
for title in frame.ix[i]['title'].values.tolist():
print(' %s,' % title, end='')
print() #add whitespace
print() #add whitespace
print()
print()
は文字列のみに適用することができ、事前
「とにかく、私はこの種のエラーを発見しました」という行は? –