2012-06-27 22 views
2

我试图运行scikit学习的K-means例如从scikit学习的官方网站: http://scikit-learn.org/dev/auto_examples/cluster/plot_cluster_iris.html#example-cluster-plot-cluster-iris-py错误而执行scikit学习的K-means例如

我被安装了所有的库(例如,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' 

这是否与scikit-learn版本有关?我正在使用ver。在MAC OS X Lion上为0.11。

回答

13

您正在查看scikit-learn的出血性边缘开发版本的文档。该示例的稳定(0.11)版本是heren_clusters将在0.12中引入,而在旧版本中则使用k代替(尽管k将在一段时间内保持向后兼容性)。

1

你需要更新升级sklearn sklern

你需要 Scikit学习要求: 的Python(> = 2.6或> = 3.3), NumPy的(> = 1.6.1), SciPy的(> = 0.9)。

只需输入端子(假设你已经安装了PIP)

PIP安装-U numpy的SciPy的scikit学习