Last active
March 21, 2020 17:41
-
-
Save tarlanahad/4854ca88d89a496c47d3ddc0c3cc9b4b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def distances(self, w, with_lagrange=True): | |
distances = self.y * (np.dot(self.X, w)) - 1 | |
# get distance from the current decision boundary | |
# by considering 1 width of margin | |
if with_lagrange: # if lagrange multiplier considered | |
# if distance is more than 0 | |
# sample is not on the support vector | |
# Lagrange multiplier will be 0 | |
distances[distances > 0] = 0 | |
return distances |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment