Reputation: 13088
When I run
import numpy as np
from sklearn.cluster import MeanShift, estimate_bandwidth
estimate_bandwidth(np.array([1,2,3,4,5,6]))
I get the error
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "[..]/anaconda2/envs/reifen/lib/python2.7/site-packages/sklearn/cluster/mean_shift_.py", line 72, in estimate_bandwidth
d, _ = nbrs.kneighbors(X[batch, :], return_distance=True)
IndexError: too many indices for array
I understand that the dimensionality of the array is not correct - but I am not sure what I did wrong here - the code isn't that long. Can estimate_bandwidth only be used with data that is multivariate?
Upvotes: 0
Views: 1106
Reputation: 865
Ypu should do something like this:
import numpy as np
from sklearn.cluster import MeanShift, estimate_bandwidth
array = np.array([1,2,3,4,5,6])
d = estimate_bandwidth(array.reshape(len(array),1))
Upvotes: 1