ageron / ageron/handson-ml2

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

Ouverte
#198 3 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Jupyter Notebook
Étoiles
30k
Forks
13.1k
Métriques de merge des PR
Aucune PR mergée en 30 j

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

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.