簡體   English   中英

sci-kit 學習凝聚聚類錯誤

[英]sci-kit learn agglomerative clustering error

我正在嘗試使用 sklearn 進行凝聚聚類。 在擬合步驟中,我收到此錯誤。 錯誤不會一直出現,如果我更改數據點的數量,那么我可能不會收到錯誤和凝聚聚類。 我不太確定如何調試它。 我已經使用fillnan確保我的數據數組中沒有NaN值。 關於為什么會發生這種情況的任何想法都會有所幫助。

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-38-8acbe956f76e> in <module>()
     13     agg = AgglomerativeClustering(n_clusters=k,affinity="euclidean",linkage="ward")
     14     init = time.time()
---> 15     agg.fit(data)
     16     atime = time.time()
     17     labels = agg.labels_

C:\Python27\lib\site-packages\sklearn\cluster\hierarchical.pyc in fit(self, X, y)
    754                                        n_components=self.n_components,
    755                                        n_clusters=n_clusters,
--> 756                                        **kwargs)
    757         # Cut the tree
    758         if compute_full_tree:

C:\Python27\lib\site-packages\sklearn\externals\joblib\memory.pyc in __call__(self, *args, **kwargs)
    279 
    280     def __call__(self, *args, **kwargs):
--> 281         return self.func(*args, **kwargs)
    282 
    283     def call_and_shelve(self, *args, **kwargs):

C:\Python27\lib\site-packages\sklearn\cluster\hierarchical.pyc in ward_tree(X, connectivity, n_components, n_clusters, return_distance)
    189                           'for the specified number of clusters',
    190                           stacklevel=2)
--> 191         out = hierarchy.ward(X)
    192         children_ = out[:, :2].astype(np.intp)
    193 

C:\Python27\lib\site-packages\scipy\cluster\hierarchy.pyc in ward(y)
    463 
    464     """
--> 465     return linkage(y, method='ward', metric='euclidean')
    466 
    467 

C:\Python27\lib\site-packages\scipy\cluster\hierarchy.pyc in linkage(y, method, metric)
    662             Z = np.zeros((n - 1, 4))
    663             _hierarchy.linkage(dm, Z, n,
--> 664                                int(_cpy_euclid_methods[method]))
    665     return Z
    666 

scipy\cluster\_hierarchy.pyx in scipy.cluster._hierarchy.linkage (scipy\cluster\_hierarchy.c:8759)()

C:\Python27\lib\site-packages\scipy\cluster\_hierarchy.pyd in View.MemoryView.memoryview_copy_contents (scipy\cluster\_hierarchy.c:22026)()

C:\Python27\lib\site-packages\scipy\cluster\_hierarchy.pyd in View.MemoryView._err_extents (scipy\cluster\_hierarchy.c:21598)()

ValueError: got differing extents in dimension 0 (got 704882705 and 4999850001)

這是一個溢出問題,請注意 4999850001 - 2**32 = 704882705(輸出的最后一行)。 某些東西太大而無法放入 32 位整數。 您應該嘗試使用更少的數據點。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM