我有一个包含 7265 个样本和132 个特征的数据集。我想使用 scikit learn 的 meanshift 算法,但我遇到了这个错误:
Traceback (most recent call last):
File "C:\Users\OJ\Dropbox\Dt\Code\visual\facetest\facetracker_video.py", line 130, in <module>
labels, centers = getClusters(data,clusters)
File "C:\Users\OJ\Dropbox\Dt\Code\visual\facetest\facetracker_video.py", line 34, in getClusters
ms.fit(np.array(dataarray))
File "C:\python2.7\lib\site-packages\sklearn\cluster\mean_shift_.py", line 280, in fit
cluster_all=self.cluster_all)
File "C:\python2.7\lib\site-packages\sklearn\cluster\mean_shift_.py", line 137, in mean_shift
nbrs = NearestNeighbors(radius=bandwidth).fit(sorted_centers)
File "C:\python2.7\lib\site-packages\sklearn\neighbors\base.py", line 642, in fit
return self._fit(X)
File "C:\python2.7\lib\site-packages\sklearn\neighbors\base.py", line 180, in _fit
raise ValueError("data type not understood")
ValueError: data type not understood
我的代码:
dataarray = np.array(data)
bandwidth = estimate_bandwidth(dataarray, quantile=0.2, n_samples=len(dataarray))
ms = MeanShift(bandwidth=bandwidth, bin_seeding=True)
ms.fit(dataarray)
labels = ms.labels_
cluster_centers = ms.cluster_centers_
如果我检查数据变量的数据类型,我会看到:
print isinstance( dataarray, np.ndarray )
>>> True
带宽为 0.925538333061 并且dataarray.dtype
是float64
我正在使用 scikit learn 0.14.1
我可以与 sci-kit 中的其他算法进行聚类(尝试过 kmeans 和 dbscan)。我究竟做错了什么 ?
编辑:
数据可以在这里找到: (pickle 格式): http: //ojtwist.be/datatocluster.p 和: http: //ojtwist.be/datatocluster.npz