One-class SVM
Published: 2019-04-20

After reading an article these days, when the sample is extremely unbalanced, we can use a classification, that is to say, the result is because of it or not because of it. As for who it is, we don't care.On the question of dichotomy, we get either a or b.At present, I am doing abnormal event detection. For abnormal events, it is an event with a small sample size. For detecting such events, I can use One-class SVM in libsvm to train a hyperplane by using normal data. For testing with all data, it is considered a normal event within the hyperplane, otherwise it is considered an abnormal event.

In order to learn One-class SVM, I first consulted this blog on the Internet and did some quizzes. The code can run normally, mainly studying the meaning of training and prediction.

model = svmtrain(Y1,X1,'-s 2 -t 2 -n 0.01');
[Y1,Y2,Y3] = svmpredict(Y,X,model);
第一行为调用了svmtrain这句函数,-s后面跟2指的是调用了one-class-SVM,-t followed by 2 means that the kernel function calls the default  RBF kernel, a total of 4 kinds of kernel functions can be tested, with different effects. For this small experiment, the accuracy rate of using the default kernel function is the highest,-n means the degree of preventing over-fitting, tolerance of error, and the position of the trained hyperplane can be changed by adjusting this.

The second line of code calls the svmpredict function, the input parameter Y is the label of the input data, X is the input data, model is the model trained in the previous step, the svmpredict function is called together, Y1 is the label of the prediction, Y2 is the data of three rows and one column, the data of the first row represents the accuracy rate, and the data of the second row and the third row represent the data seen during regression analysis.Y3 parameter is the probability of belonging to each class when multi-class problems are involved.

can adjust the type of kernel function and adjust the penalty factor C to see the change of results.You can refer to these two articles for some more detailed explanations.

Click Open Link, click Open Link