Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit deb9862

Browse files
authored
Corrected the SVM margins
The margins are calculated wrongly. margin = |c2-c1|/sqrt(1+m^2) => c2 = margin*sqrt(1+m^2) + c1 = > y_up= m*x+ margin*sqrt(1+m^2) + c1 => y_up = (m*x+ c1) + margin*sqrt(1+m^2) => y_up = y + margin*sqrt(1+m^2)
1 parent b491dcc commit deb9862

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

_posts/scikit/svm-margins/SVM Margins.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@
171171
" # plot the parallels to the separating hyperplane that pass through the\n",
172172
" # support vectors\n",
173173
" margin = 1 / np.sqrt(np.sum(clf.coef_ ** 2))\n",
174-
" yy_down = yy + a * margin\n",
175-
" yy_up = yy - a * margin\n",
174+
" yy_down = yy + np.sqrt(1 + a ** 2) * margin\n",
175+
" yy_up = yy - np.sqrt(1 + a ** 2) * margin\n",
176176
" \n",
177177
" x_min = -4.8\n",
178178
" x_max = 4.2\n",

0 commit comments

Comments
 (0)