使用svm 函数predict 报错predict ValueError: Expected 2D array, got 1D array instead:

test_point = [ 0 ... 0.]

clf = svm.SVC()
print(clf.predict(test_point))

此时报错:
ValueError: Expected 2D array, got 1D array instead:
array=[…].
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.

更改test_point输入数组即可,

test_point = [[ 0....0.]]
print(clf.predict(test_point))

你可能感兴趣的:(使用svm 函数predict 报错predict ValueError: Expected 2D array, got 1D array instead:)