Reputation: 20889
I'm trying to run a scikit-learn K-means example from scikit-learn official site: http://scikit-learn.org/dev/auto_examples/cluster/plot_cluster_iris.html#example-cluster-plot-cluster-iris-py
I got all libraries installed (e.g., scipy, numpy, pylab). However, when executing the code, I got error message like this:
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'
Is it something to do with the scikit-learn version? I'm using ver. 0.11 on MAC OS X Lion.
Upvotes: 2
Views: 2608
Reputation: 1326
you need to upgrade sklern
for updating sklearn you need Scikit-learn requires: Python (>= 2.6 or >= 3.3), NumPy (>= 1.6.1), SciPy (>= 0.9).
simply type in terminal(assuming you have installed pip)
pip install -U numpy scipy scikit-learn
Upvotes: 1
Reputation: 363487
You're looking at the docs for the bleeding edge development version of scikit-learn. The stable (0.11) version of that example is here. n_clusters
will be introduced in 0.12, in older versions use k
instead (though k
will be around for some time for backward compatibility).
Upvotes: 13