我在12个变量的400K观测值上运行K-means聚类.最初,当我使用Kmeans代码运行单元格时,它会在2分钟后弹出一条消息,说内核被中断并将重新启动.然后需要很长时间,好像内核已经死了,代码将不再运行.
所以我尝试了125k观察,同样没有.变量.但仍然是我得到的同样的信息.
这是什么意思?这是否意味着ipython笔记本无法在125k观察中运行kmeans并杀死内核?
怎么解决这个?这对我来说非常重要. 🙁
请指教.
我使用的代码:
来自sklearn.cluster导入KMeans
来自sklearn.metrics导入silhouette_score
# Initialize the clusterer with n_clusters value and a random generator
# seed of 10 for reproducibility.
kmeans=KMeans(n_clusters=2,init='k-means++',n_init=10, max_iter=100)
kmeans.fit(Data_sampled.ix[:,1:])
cluster_labels = kmeans.labels_
# The silhouette_score gives the average value for all the samples.
# This gives a perspective into the density and separation of the formed
# clusters
silhouette_avg = silhouette_score(Data_sampled.ix[:,1:],cluster_labels)