Skip to content

Commit

Permalink
[static] added fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mzwiessele committed Apr 21, 2016
1 parent 0c180b3 commit 87af7e2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
12 changes: 6 additions & 6 deletions GPy/kern/src/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,30 +195,30 @@ def update_gradients_expectations(self, dL_dpsi0, dL_dpsi1, dL_dpsi2, Z, variati
class Precomputed(Fixed):
def __init__(self, input_dim, covariance_matrix, variance=1., active_dims=None, name='precomputed'):
"""
Class for precomputed kernels, indexed by X
Class for precomputed kernels, indexed by columns in X
Usage example:
import numpy as np
from GPy.models import GPClassification
from GPy.kern import Precomputed
from sklearn.cross_validation import LeaveOneOut
n = 10
d = 100
X = np.arange(n).reshape((n,1)) # column vector of indices
y = 2*np.random.binomial(1,0.5,(n,1))-1
X0 = np.random.randn(n,d)
k = np.dot(X0,X0.T)
kern = Precomputed(1,k) # k is a n x n covariance matrix
cv = LeaveOneOut(n)
ypred = y.copy()
for train, test in cv:
m = GPClassification(X[train], y[train], kernel=kern)
m.optimize()
ypred[test] = 2*(m.predict(X[test])[0]>0.5)-1
:param input_dim: the number of input dimensions
:type input_dim: int
:param variance: the variance of the kernel
Expand Down
9 changes: 6 additions & 3 deletions GPy/testing/kernel_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
# Licensed under the BSD 3-clause license (see LICENSE.txt)

import unittest
import numpy as np
from unittest.case import skip

import GPy
from GPy.core.parameterization.param import Param
import numpy as np

from ..util.config import config
from unittest.case import skip


verbose = 0

Expand Down Expand Up @@ -347,7 +350,7 @@ def test_standard_periodic(self):
k = GPy.kern.StdPeriodic(self.D)
k.randomize()
self.assertTrue(check_kernel_gradient_functions(k, X=self.X, X2=self.X2, verbose=verbose))

def test_Precomputed(self):
Xall = np.concatenate([self.X, self.X2])
cov = np.dot(Xall, Xall.T)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ Python 2.7, 3.4 and higher
## Citation

@Misc{gpy2014,
author = {{The GPy authors}},
author = {{GPy}},
title = {{GPy}: A Gaussian process framework in python},
howpublished = {\url{http://github.com/SheffieldML/GPy}},
year = {2012--2015}
year = {since 2012}
}

### Pronounciation:
Expand Down

0 comments on commit 87af7e2

Please sign in to comment.