我收到此错误,我应该重塑它,如何完成? ValueError:找到的数组为暗3。估计量应小于等于2

时间:2019-04-24 20:44:11

标签: python python-3.x scikit-learn

我收到此ValueError:找到的数组具有暗3。预期的估计量<= 2。 我在此行出现错误

from sklearn.tree import DecisionTreeClassifier

my_decisiontree = DecisionTreeClassifier()
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2,random_state=4)
my_decisiontree.fit(X_train, y_train)
y_predict_dt = my_decisiontree.predict(X_test)
from sklearn.metrics import accuracy_score
print(y_predict_dt)
accuracy = accuracy_score(y_test, y_predict_dt)

print(accuracy)


----> 7 my_decisiontree.fit(X_train, y_train)
 ValueError: Found array with dim 3. Estimator expected <= 2.

这是我先前在程序中打印的形状

#convert to array
img_data = np.array(img_data_list)

#convert to float, 0 - 1
img_data = img_data.astype('float32')

#scale
img_data /= 255
print (img_data.shape)

(5856, 64, 64)

我需要重塑吗?以及如何完成?

0 个答案:

没有答案