【发布时间】:2016-07-31 05:38:45
【问题描述】:
我正在尝试使用 kmeans 对我的词向量进行聚类,如 here 所述。 我正在使用的代码sn-p
# Set "k" (num_clusters) to be 1/5th of the vocabulary size, or an
# average of 5 words per cluster
word_vectors = model.syn0
num_clusters = word_vectors.shape[0] / 5
# Initalize a k-means object and use it to extract centroids
kmeans_clustering = KMeans( n_clusters = num_clusters )
idx = kmeans_clustering.fit_predict( word_vectors )
我收到以下错误 TypeError: 'float' 对象不能被解释为整数
有人可以帮忙
【问题讨论】:
标签: python-3.x k-means word2vec