2
votes

Lets say my feature vector is (x1, x2, ...xn)

Could anyone give me a code to train one-class SVM using libSVM?

How should I learn the parameters using cross validation.

1

1 Answers

3
votes

This may help you

label=ones(Number Of your training instances,1); % You should generate labels for your only class!
model = svmtrain( label, Training Data , '-s 2 -t 2  -n 0.5' ) ; % You can change the parameters
[predicted_label,accuracy]=svmpredict(TestLabels,Test Set, model);