mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-30 14:35:15 +02:00
commit
2e7ab4a5d8
3 changed files with 28 additions and 1 deletions
|
|
@ -32,7 +32,7 @@ from .src.trunclinear import TruncLinear,TruncLinear_inf
|
|||
from .src.splitKern import SplitKern,DEtime
|
||||
from .src.splitKern import DEtime as DiffGenomeKern
|
||||
from .src.spline import Spline
|
||||
from .src.basis_funcs import LogisticBasisFuncKernel, LinearSlopeBasisFuncKernel, BasisFuncKernel, ChangePointBasisFuncKernel, DomainKernel
|
||||
from .src.basis_funcs import LogisticBasisFuncKernel, LinearSlopeBasisFuncKernel, BasisFuncKernel, ChangePointBasisFuncKernel, DomainKernel, PolynomialBasisFuncKernel
|
||||
from .src.grid_kerns import GridRBF
|
||||
|
||||
from .src.sde_matern import sde_Matern32
|
||||
|
|
|
|||
|
|
@ -102,6 +102,26 @@ class BasisFuncKernel(Kern):
|
|||
phi2 = phi2[:, None]
|
||||
return phi1.dot(phi2.T)
|
||||
|
||||
class PolynomialBasisFuncKernel(BasisFuncKernel):
|
||||
def __init__(self, input_dim, degree, variance=1., active_dims=None, ARD=True, name='polynomial_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(PolynomialBasisFuncKernel, 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):
|
||||
def __init__(self, input_dim, start, stop, variance=1., active_dims=None, ARD=False, name='linear_segment'):
|
||||
|
|
|
|||
|
|
@ -495,6 +495,13 @@ class KernelGradientTestsContinuous(unittest.TestCase):
|
|||
k = GPy.kern.Add(ks)
|
||||
self.assertTrue(check_kernel_gradient_functions(k, X=self.X, X2=self.X2, verbose=verbose))
|
||||
|
||||
def test_basis_func_poly(self):
|
||||
ks = []
|
||||
for i in range(self.X.shape[1]):
|
||||
ks.append(GPy.kern.PolynomialBasisFuncKernel(1, 5, ARD=i%2==0, active_dims=[i]))
|
||||
k = GPy.kern.Add(ks)
|
||||
self.assertTrue(check_kernel_gradient_functions(k, X=self.X, X2=self.X2, verbose=verbose))
|
||||
|
||||
def test_basis_func_domain(self):
|
||||
start_stop = np.random.uniform(self.X.min(0), self.X.max(0), (4, self.X.shape[1])).T
|
||||
start_stop.sort(axis=1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue