Dieser Code ist für die Indexierung und Sortierung auf jedem Cluster zu identifizieren, welche die oberen n sind (ich wählte n = 6) Wörter, die dem Clusterschwerpunkt am nächsten sind. Wie auch immer, ich fand diese Art von Fehler: 'float' Objekt hat kein Attribut 'encode''float' Objekt hat kein Attribut 'encode'
kann mir jemand helfen? der Code ist folgende:
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()
Ihnen im Voraus danken
'Anyway, ich fand diese Art von Fehler 'Auf welcher Linie? –