执行scikit-learn K-means示例时出错

clw*_*wen 2 python scikit-learn

我正在尝试从scikit-learn官方网站上运行scikit-learn K-means示例:http://scikit-learn.org/dev/auto_examples/cluster/plot_cluster_iris.html#example-cluster-plot-cluster-iris -吡咯

我安装了所有库(例如,scipy,numpy,pylab).但是,在执行代码时,我收到如下错误消息:

Traceback (most recent call last):
  File "plot_cluster_iris.py", line 41, in <module>
    estimators = {'k_means_iris_3': KMeans(n_clusters=3),
TypeError: __init__() got an unexpected keyword argument 'n_clusters'
Run Code Online (Sandbox Code Playgroud)

这与scikit-learn版本有关吗?我正在使用ver.MAC OS X Lion上的0.11.

Fre*_*Foo 13

您正在查看scikit-learn的前沿开发版本的文档.这个例子的稳定版(0.11)就在这里.n_clusters将在0.12中引入,在旧版本中使用k(尽管k为了向后兼容性将会存在一段时间).