【发布时间】:2016-12-15 13:45:01
【问题描述】:
我是 kmeans 聚类方法的新手。我尝试在 python 中对一维字符串数组数据进行聚类。
以下是我的数据:
expertise=['
Bioactive Surfaces and Scaffolds for Regenerative Medicine',
'Drug/gene delivery science',
'RNA nanomedicine', 'Immuno/bio/nano-engineering', 'Biomaterials', 'Nanomedicine',
'Biobased Chemicals and Polymers',
'Membranes Science & Technology',
'Modeling of Infectious and Lifestyle-related Diseases']
km = KMeans(n_clusters=2)
km.fit(expertise)
我得到 ValueError: could not convert string to float:
所以我想知道如何在字符串数据上应用 kmeans,或者有什么方法可以将数据更改为二维?
【问题讨论】:
-
一串字符串应该是什么意思?
-
我已经在 kmeans 上尝试过坐标数据,并且效果很好。所以我想知道字符串数据是否有效
-
准确地说,这不是“字符串数据”,而只是字符串。如果您找到一种从它们获取数据的方法(例如使用汉明距离或类似的东西),当然可以制作“字符串簇”,但 sklearn 无法为您做到这一点,NLTK 可能有那种东西。
标签: python scikit-learn k-means