使用numpy.concatenate

时间:2019-04-13 19:53:06

标签: python-3.x numpy scikit-multilearn

因此,基本上我有两个维度分别为x_chunk的numpy数组y_chunk[10,512,512,50]。我使用以下代码将其转换为尺寸[10,13107200]

x_chunk=x_chunk.reshape(10,13107200)
y_chunk=y_chunk.reshape(10,13107200)

现在我正在使用skmultiflow KNN Classifier,并尝试使用partial_fit

拟合这些数据
model.partial_fit(x_chunk, y_chunk)

但是我收到此错误:

ValueError                                Traceback (most recent call last)
<ipython-input-26-d3e5ffef750e> in <module>()
     53     x_chunk=x_chunk.reshape(10,13107200)
     54     y_chunk=y_chunk.reshape(10,13107200)
---> 55     model.partial_fit(x_chunk, y_chunk)
     56     n_loop += 1
     57 

/usr/local/lib/python3.6/dist-packages/skmultiflow/lazy/knn.py in partial_fit(self, X, y, classes, weight)
    178 
    179         for i in range(r):
--> 180             self.window.add_element(np.asarray([X[i]]), np.asarray([[y[i]]]))
    181         return self
    182 

/usr/local/lib/python3.6/dist-packages/skmultiflow/utils/data_structures.py in add_element(self, X, y)
    968             raise TypeError("None type not supported as the buffer, call configure() to set up the InstanceWindow")
    969 
--> 970         aux = np.concatenate((X, y), axis=1)
    971         self._buffer = np.concatenate((self._buffer, aux), axis=0)
    972         self._n_samples += 1

ValueError: all the input arrays must have same number of dimensions

它说数组的尺寸应该相同,但是两个数组都具有相同的尺寸,那是什么问题呢?

修改

我使用的模型是:

from skmultiflow.lazy import KNN
model = KNN(n_neighbors=8, max_window_size=2000, leaf_size=40)

0 个答案:

没有答案