简体   繁体   中英

train and predict in RBF Support Vector Machine

I'm trying to run of SVM RBF regression on my train and test dataset.

[svm = SVC(kernel='rbf', random_state=0 , C=C, gamma=0.9)
  svm.fit(NewX , NewY)]

the train step works without any problem. However, in the prediction step svm.predict it gives me this error

"ValueError: all the input array dimensions except for the concatenation axis must match exactly"

Call to the prediction method:

[Z = svm.predict(np.c_[NX_Test.ravel(),NY_Test.ravel()])
    Z = Z.reshape(NX_Test.shape)]

Data Format:

  • My training data set is a list of 80 input examples, where each example is a signal of 100 samples)

  • My testing data is a list of 20 input examples, where each example is also a signal consisting of 100 samples)

https://pythonspot.com/support-vector-machine/

Did you check if the dimensions of all your training samples match?

An SVM needs the samples, the feature vectors, to have the same dimension. Consider the follwing feature vector in libSVM format:

1:0.2 2:0.4 3:1.0 4:0.07 5:0.3

The first value represents the index and the second associated value. This vector has a dimension of 5 and hence, all your other feature vectors must match this dimension for training. After the training, the vectors you want to predict must also exactly match this dimension. So, verify that this constraint is satisfied.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM