【发布时间】:2018-07-13 14:19:39
【问题描述】:
我有以下 Python 代码 sn-p,我试图在某些数据上运行 SVC(使用的库是 scikit-learn:
(trainFeat, testFeat, trainLabels, testLabels) = train_test_split(
data, data_labels, test_size=0.20, random_state=42)
model = SVC(kernel='poly', max_iter=10,probability=True,class_weight='balanced')
model.fit(np.reshape(trainFeat, (124,-1)), trainLabels)
accuracy = model.score(testFeat, testLabels)
print('Accuracy: {:.2f}%'.format(acc * 100))
但是,accuracy = model.score(testFeat, testLabels) 出现以下错误:
ValueError: Found array with dim 3. Estimator expected <= 2.
我应该怎么做才能修复这个错误?
谢谢。
【问题讨论】:
-
你把这个问题发了两次,为什么?
-
@Banana 这个问题其实不一样。第一个与拟合模型有关,但这个问题是关于找到“分数”
标签: python arrays numpy model scikit-learn