Last active
April 11, 2017 13:29
-
-
Save emilemathieu/026df8545b880e7814ddc081a55a0e70 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
import numpy as np | |
class Kernel(object): | |
"""Collection of usual kernels""" | |
@staticmethod | |
def linear(): | |
def f(x, y): | |
return np.inner(x, y) | |
return f | |
@staticmethod | |
def rbf(gamma): | |
def f(x, y): | |
exponent = - gamma * np.linalg.norm(x-y) ** 2 | |
return np.exp(exponent) | |
return f | |
@staticmethod | |
def quadratic(offset=0.0, gamma=1.0): | |
def f(x, y): | |
return (gamma * (offset + np.dot(x, y)) ) ** 2 | |
return f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment