[Mark] python 聚类分析 kmeans() 函数使用时报错
来源:互联网 发布:华润邮箱域名 编辑:程序博客网 时间:2024/06/16 23:36
from pylab import *from scipy.cluster.vq import *list1=[88,74,96,85]list2=[92,99,95,94]list3=[91,87,99,95]list4=[78,99,97,81]list5=[88,78,98,84]data=vstack((list1,list2,list3,list4,list5))centroids,_=kmeans(data,2)result,_=vq(data,centroids)print result
会出现报错:
runfile('E:/python/wanzhuanshuju/kmeansStu.py', wdir='E:/python/wanzhuanshuju')
Traceback (most recent call last):
File "<ipython-input-7-354e9e534bf9>", line 1, in <module>
runfile('E:/python/wanzhuanshuju/kmeansStu.py', wdir='E:/python/wanzhuanshuju')
File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 685, in runfile
execfile(filename, namespace)
File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 71, in execfile
exec(compile(scripttext, filename, 'exec'), glob, loc)
File "E:/python/wanzhuanshuju/kmeansStu.py", line 16, in <module>
centroids,_=kmeans(data,2)
File "C:\Python27\lib\site-packages\scipy\cluster\vq.py", line 520, in kmeans
book, dist = _kmeans(obs, guess, thresh=thresh)
File "C:\Python27\lib\site-packages\scipy\cluster\vq.py", line 405, in _kmeans
code_book, has_members = _vq.update_cluster_means(obs, obs_code, nc)
File "scipy\cluster\_vq.pyx", line 345, in scipy.cluster._vq.update_cluster_means (scipy\cluster\_vq.c:4572)
TypeError: type other than float or double not supported
这时候把一个list中的一个元素改成float就可以成功运行并得到结果。
from pylab import *from scipy.cluster.vq import *list1=[88.0,74,96,85]list2=[92,99,95,94]list3=[91,87,99,95]list4=[78,99,97,81]list5=[88,78,98,84]data=vstack((list1,list2,list3,list4,list5))centroids,_=kmeans(data,2)result,_=vq(data,centroids)print result
- [Mark] python 聚类分析 kmeans() 函数使用时报错
- [Mark] python 聚类分析 kmeans() 函数使用时报错
- Python KMeans聚类分析
- 使用Python进行聚类分析
- spark:聚类分析KMeans--47
- kmeans函数使用实例
- Java实现聚类分析Kmeans算法
- sklearn中kmeans聚类分析常用命令
- 【二分-kMeans算法】二分K均值聚类分析与Python代码实现
- python使用jieba分词时报错
- 聚类分析:k-means和appropriate kmeans
- 聚类分析(一)——Kmeans
- spark:第一次接触聚类分析Kmeans算法--16
- 聚类分析之R语言篇 (Kmeans)
- 基于Spark ML 聚类分析实战的KMeans
- Python Kmeans
- python-kmeans
- python爬虫时报错
- Ignatius and the Princess IV
- Common Subsequence||HDU1159
- RocketMQ存储篇——MapedFileQueue
- 小程序-初学篇
- 面试题55. 表示数值的字符串
- [Mark] python 聚类分析 kmeans() 函数使用时报错
- [RK3288][Android6.0] 调试笔记 --- pmu(rk818)寄存器读写
- 网易校招编程题之藏宝图
- 关键字的作用及区别汇总
- [LeetCode]459. Repeated Substring Pattern
- It is currently in use by another gradle instance
- 在 Visual Studio Code 中使用Git
- 快递手持终端是什么?
- Sublime Text3工具使用盘点