Skip to content

Instantly share code, notes, and snippets.

@tarlanahad
Last active March 21, 2020 17:41
Show Gist options
  • Save tarlanahad/4854ca88d89a496c47d3ddc0c3cc9b4b to your computer and use it in GitHub Desktop.
Save tarlanahad/4854ca88d89a496c47d3ddc0c3cc9b4b to your computer and use it in GitHub Desktop.
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