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.
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_clusterswill be introduced in 0.12, in older versions usekinstead (thoughkwill be around for some time for backward compatibility).