Home | Trees | Indices | Help |
|
---|
|
1 # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- 2 # vi: set ft=python sts=4 ts=4 sw=4 et: 3 ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 4 # 5 # See COPYING file distributed along with the PyMVPA package for the 6 # copyright and license terms. 7 # 8 ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 9 """Unit tests for PyMVPA GPR.""" 10 11 import unittest 12 13 from mvpa.base import externals 14 15 from mvpa.misc import data_generators 16 from mvpa.clfs.kernel import KernelLinear as GeneralizedLinearKernel 17 from mvpa.clfs.gpr import GPR 18 19 from tests_warehouse import * 20 from numpy.testing import assert_array_equal, assert_array_almost_equal 21 22 if __debug__: 23 from mvpa.base import debug 24 252760 61 6229 dataset = data_generators.linear1d_gaussian_noise() 30 k = GeneralizedLinearKernel() 31 clf = GPR(k) 32 clf.train(dataset) 33 y = clf.predict(dataset.samples) 34 assert_array_equal(y.shape, dataset.labels.shape)35 3840 """Smoke test for running model selection while getting GPRWeights 41 """ 42 if not externals.exists('openopt'): 43 return 44 45 dataset = datasets['uni2small'] #data_generators.linear1d_gaussian_noise() 46 k = GeneralizedLinearKernel() 47 clf = GPR(k, enable_states=['log_marginal_likelihood']) 48 sa = clf.getSensitivityAnalyzer() # should be regular weights 49 sa_ms = clf.getSensitivityAnalyzer(flavor='model_select') # with model selection 50 def prints(): 51 print clf.states.log_marginal_likelihood, clf.kernel.Sigma_p, clf.kernel.sigma_052 53 sa(dataset) 54 lml = clf.states.log_marginal_likelihood 55 56 sa_ms(dataset) 57 lml_ms = clf.states.log_marginal_likelihood 58 59 self.failUnless(lml_ms > lml)64 return unittest.makeSuite(GPRTests)65 66 67 if __name__ == '__main__': 68 import runner 69
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Mon Apr 23 23:09:41 2012 | http://epydoc.sourceforge.net |