Skip to content

Commit

Permalink
Add doctest for Kernet _linear func
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Pasutti committed Sep 18, 2024
1 parent 8d4c9e8 commit 94b1403
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions machine_learning/sequential_minimum_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,13 @@ def _polynomial(self, v1, v2):
return (self.gamma * np.inner(v1, v2) + self.coef0) ** self.degree

def _linear(self, v1, v2):
"""
>>> from machine_learning.sequential_minimum_optimization import Kernel
>>> kernel = Kernel(kernel='linear')
>>> result = kernel._polynomial(np.array([1, 2]), np.array([2, 3]))
>>> int(result) == 8
True
"""
return np.inner(v1, v2) + self.coef0

def _rbf(self, v1, v2):
Expand Down

0 comments on commit 94b1403

Please sign in to comment.