mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-21 14:05:14 +02:00
chg: added polynomial basis func kernel
This commit is contained in:
parent
59be79e962
commit
747d24d2fa
1 changed files with 20 additions and 0 deletions
|
|
@ -102,6 +102,26 @@ class BasisFuncKernel(Kern):
|
||||||
phi2 = phi2[:, None]
|
phi2 = phi2[:, None]
|
||||||
return phi1.dot(phi2.T)
|
return phi1.dot(phi2.T)
|
||||||
|
|
||||||
|
class PolinomialBasisFuncKernel(BasisFuncKernel):
|
||||||
|
def __init__(self, input_dim, degree, variance=1., active_dims=None, ARD=True, name='polinomial_basis'):
|
||||||
|
"""
|
||||||
|
A linear segment transformation. The segments start at start, \
|
||||||
|
are then linear to stop and constant again. The segments are
|
||||||
|
normalized, so that they have exactly as much mass above
|
||||||
|
as below the origin.
|
||||||
|
|
||||||
|
Start and stop can be tuples or lists of starts and stops.
|
||||||
|
Behaviour of start stop is as np.where(X<start) would do.
|
||||||
|
"""
|
||||||
|
self.degree = degree
|
||||||
|
super(PolinomialBasisFuncKernel, self).__init__(input_dim, variance, active_dims, ARD, name)
|
||||||
|
|
||||||
|
@Cache_this(limit=3, ignore_args=())
|
||||||
|
def _phi(self, X):
|
||||||
|
phi = np.empty((X.shape[0], self.degree+1))
|
||||||
|
for i in range(self.degree+1):
|
||||||
|
phi[:, [i]] = X**i
|
||||||
|
return phi
|
||||||
|
|
||||||
class LinearSlopeBasisFuncKernel(BasisFuncKernel):
|
class LinearSlopeBasisFuncKernel(BasisFuncKernel):
|
||||||
def __init__(self, input_dim, start, stop, variance=1., active_dims=None, ARD=False, name='linear_segment'):
|
def __init__(self, input_dim, start, stop, variance=1., active_dims=None, ARD=False, name='linear_segment'):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue