Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to learn SVM algorithm

Shulou Source: shulou.com Published: 2022-06-01 23:25:01 10月01日 Update

This article to share with you is about how to learn SVM algorithm, Xiaobian think quite practical, so share to everyone to learn, I hope you can read this article after some harvest, not much to say, follow Xiaobian to see it.

SVM is a classification algorithm based on statistical learning theory, which is suitable for dealing with data sets with high-dimensional features.

Here are a few I think are pretty good:

Support Vector Machine (SVM): blog.csdn.net/v_july_v/article/details/7624837

This article is very detailed, advancing from shallow to deep.

There is also a more popular simple version: teach you to implement SVM algorithm: blog.csdn.net/alvine008/article/details/9097105

SVN principle is more complex, but the idea is very simple, in a word, it is to find an optimal hyperplane in high-dimensional space through some kernel function, which can separate two kinds of data.

For different datasets, the classification effect of different kernel functions may be completely different. There are several optional kernel functions:

Linear function: A linear function of the form K(x,y)=x*y;

A polynomial function of the form K(x,y)=[(x·y)+1]^d;

Radial basis function: K(x,y)=exp(-|x-y| ^2/d^2);

Sigmoid function: Sigmoid function mentioned in the previous article.

Let's take a few data sets and give Python code directly to see the effect:

Test 1: Height and Weight Data

The results are as follows:

As you can see, SVM with a polynomial kernel of degree 3 gives the best results for this dataset.

Test 3: Circular Boundary

Finally, we test a case where the data classification boundary is circular: one class inside the circle and one class outside the prototype. See how SVM performs on this class of nonlinear data:

The test data generation code is as follows:

The test results are as follows:

SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0, degree=3, gamma=0.0, kernel='linear', max_iter=-1, probability=False, random_state=None,

shrinking=True, tol=0.001, verbose=False)

0.65

SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0, degree=3, gamma=0.0, kernel='poly', max_iter=-1, probability=False, random_state=None,

shrinking=True, tol=0.001, verbose=False)

0.675

SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0, degree=3, gamma=0.0, kernel='rbf', max_iter=-1, probability=False, random_state=None,

shrinking=True, tol=0.001, verbose=False)

0.9625

SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0, degree=3, gamma=0.0, kernel='sigmoid', max_iter=-1, probability=False, random_state=None,

shrinking=True, tol=0.001, verbose=False)

0.65

It can be seen that for this boundary, SVM of radial basis functions gives approximately perfect classification results.

The above is how to learn SVM algorithm, Xiaobian believes that some knowledge points may be seen or used in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Tags: Functions data tests algorithms learning classification circles polynomials that is effects articles results boundaries differences popularity code vectors radial more knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Tech Info OPPO Reno NVidia vpn