我有下面的Python代码片段,我试图在其中对一些数据运行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.
我应该怎么做来修复这个错误?你知道吗
谢谢。你知道吗
我猜,你预测了三节课。它给你三维数组,每个类的概率。你知道吗
尝试这样做:
当我把cᴏʟᴅsᴘᴇᴇᴅ的建议应用到我的另一个问题here时,代码起作用了:
相关问题 更多 >
编程相关推荐