Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
308 views
in Technique[技术] by (71.8m points)

python - How is classification mathematically done in SVM if target is labeled as 0 and 1?

My dataset has feature columns and a target label of 0 and 1.

When I use SVM classifier for binary classification it predicts well.

But my question is how is it mathematically predicted.?

The marginal hyperplanes H1 and H2 have the equations: W^T X +b >= 1

meaning if greater than +1 it falls in one class. And if less than -1, it falls in another class.

But we have given the target label 0 and 1.

How actually is it done mathematically?

Anyone expert please.....

question from:https://stackoverflow.com/questions/66048927/how-is-classification-mathematically-done-in-svm-if-target-is-labeled-as-0-and-1

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Basically, SVM wants to find the optimal hyperplane that splits the datapoints in such way that the margin between the closest datapoints of each class (the so-called support vectors) is maximized. This all breaks down to the following Lagrangian optimization problem: enter image description here

  • w:vector that determines the optimum hyperplane ( for intuition, make yourself familiar with the geometrical meaning of a dot product)

  • (w^T?x_i+b) is a scalar and displays the geometrical distance between single datapoint x_i and the maximum margin hyperplane

  • b is a bias vector ( I think it comes from indetermined integral in derivation of SVM) more on that you can find here: University Stanford -Computer Science Lecture 3-SVM

  • λ_i the Lagrangian multiplier

  • y_i the normalized classification boundary

Solving the optimization problem leads to all necessary parameters of w, b, and lambda.

To answer you quesiton in one sentence: The class boundaries [-1,1] are set arbitrarily. It is really just definition. enter image description here

The labels of your binary data [0;1] (so-called dummy varaibles) have nothing to with the boundaries. It is just a convenient way to label binary data. The labels are only needed to link the features to its corresponding class or category.

The only non paramter in Formula (8) is x_i , your datapoint in feature space.

At least thats how I understand SVM. Feel free to correct me if I am wrong or unprecise.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...