ageron / ageron/handson-ml2

[Chapter 5 - SVM] - Bias Term and calculating the Support Vectors

Open
#198 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
30k
Forks
13.1k
PR merge metrics
No merged PRs in 30d

Description

Hi,

I have 2 queries on the code for Chapter 5: SVMs:

1. Why is the bias term in the code for the SVM equal to the decision function with (mean/scale) as the input?

In the code, b is written as:

b = svm_clf2.decision_function([-scaler.mean_ / scaler.scale_]) which is: b = array([-9.76416467])

Where if you disregard the scale var for now, effectively is the decision function on the mean of both the 2 features X1 and X2. ~ decision_function([mean of feature X1, mean of feature X2

**Does this mean that the bias term is always value / output the model generates for the mean values of the features?

2. when generating the support vectors in the code, the support vector indexes are given by the following:

support_vectors_idx = (t * (X.dot(w) + b) < 1).ravel()

However I thought that the support vectors were all those instances on the edge which I thought would satisfy this condition:

(t * (X.dot(w) + b) > -1) & (t * (X.dot(w) + b) < 1)

as this would be all of the instances who fall inside the decision boundaries at -1 and 1.

OR is it that the equation / conditions satisfying hard margins is that (t * (X.dot(w) + b) >= 1) and so all Support Vectors are the opposite of that condition and so:

Support vectors have the constraint: (t * (X.dot(w) + b) < 1)

Any help would be greatly appreciated.

cheers,
Dan

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.