<s> from __future__ import print_function <EOL> from builtins import zip <EOL> import unittest <EOL> import numpy as np <EOL> import pyGPs <EOL> class ModelTests ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> regData = np . load ( '<STR_LIT>' ) <EOL> self . xr = regData [ '<STR_LIT:x>' ] <EOL> self . yr = regData [ '<STR_LIT:y>' ] <EOL> self . zr = regData [ '<STR_LIT>' ] <EOL> self . ur = np . array ( [ [ - <NUM_LIT:1> ] , [ - <NUM_LIT> ] , [ - <NUM_LIT:0.5> ] , [ <NUM_LIT> ] , [ <NUM_LIT:1.> ] ] ) <EOL> clsData = np . load ( '<STR_LIT>' ) <EOL> self . xc = clsData [ '<STR_LIT:x>' ] <EOL> self . yc = clsData [ '<STR_LIT:y>' ] <EOL> self . zc = clsData [ '<STR_LIT>' ] <EOL> u1 , u2 = np . meshgrid ( np . linspace ( - <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:5> ) , np . linspace ( - <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:5> ) ) <EOL> self . uc = np . array ( list ( zip ( np . reshape ( u2 , ( np . prod ( u2 . shape ) , ) ) , np . reshape ( u1 , ( np . prod ( u1 . shape ) , ) ) ) ) ) <EOL> def checkRegressionOutput ( self , model ) : <EOL> nn , D = self . zr . shape <EOL> self . assertTrue ( model . ym . shape == ( nn , <NUM_LIT:1> ) ) <EOL> self . assertTrue ( model . ys2 . shape == ( nn , <NUM_LIT:1> ) ) <EOL> self . assertTrue ( model . fm . shape == ( nn , <NUM_LIT:1> ) ) <EOL> self . assertTrue ( model . fs2 . shape == ( nn , <NUM_LIT:1> ) ) <EOL> def checkClassificationOutput ( self , model ) : <EOL> nn , D = self . zc . shape <EOL> self . assertTrue ( model . ym . shape == ( nn , <NUM_LIT:1> ) ) <EOL> self . assertTrue ( model . ys2 . shape == ( nn , <NUM_LIT:1> ) ) <EOL> self . assertTrue ( model . fm . shape == ( nn , <NUM_LIT:1> ) ) <EOL> self . assertTrue ( model . fs2 . shape == ( nn , <NUM_LIT:1> ) ) <EOL> def test_GPR ( self ) : <EOL> print ( "<STR_LIT>" ) <EOL> model = pyGPs . GPR ( ) <EOL> m = pyGPs . mean . Zero ( ) <EOL> k = pyGPs . cov . RBF ( ) <EOL> model . setPrior ( mean = m , kernel = k ) <EOL> model . setOptimizer ( "<STR_LIT>" , num_restarts = <NUM_LIT:10> ) <EOL> model . optimize ( self . xr , self . yr ) <EOL> model . predict ( self . zr ) <EOL> self . checkRegressionOutput ( model ) <EOL> def test_GPC ( self ) : <EOL> print ( "<STR_LIT>" ) <EOL> model = pyGPs . GPC ( ) <EOL> m = pyGPs . mean . Zero ( ) <EOL> k = pyGPs . cov . RBF ( ) <EOL> model . setPrior ( mean = m , kernel = k ) <EOL> model . optimize ( self . xc , self . yc ) <EOL> model . predict ( self . zc ) <EOL> self . checkClassificationOutput ( model ) <EOL> model = pyGPs . GPC ( ) <EOL> m = pyGPs . mean . Zero ( ) <EOL> k = pyGPs . cov . RBF ( ) <EOL> model . setPrior ( mean = m , kernel = k ) <EOL> model . useInference ( "<STR_LIT>" ) <EOL> model . optimize ( self . xc , self . yc ) <EOL> model . predict ( self . zc ) <EOL> self . checkClassificationOutput ( model ) <EOL> def test_GPR_FITC ( self ) : <EOL> print ( "<STR_LIT>" ) <EOL> model = pyGPs . GPR_FITC ( ) <EOL> m = pyGPs . mean . Zero ( ) <EOL> k = pyGPs . cov . RBF ( ) <EOL> model . setPrior ( mean = m , kernel = k , inducing_points = self . ur ) <EOL> model . setOptimizer ( "<STR_LIT>" , num_restarts = <NUM_LIT:10> ) <EOL> model . optimize ( self . xr , self . yr ) <EOL> model . predict ( self . zr ) <EOL> self . checkRegressionOutput ( model ) <EOL> def test_GPC_FITC ( self ) : <EOL> print ( "<STR_LIT>" ) <EOL> model = pyGPs . GPC_FITC ( ) <EOL> m = pyGPs . mean . Zero ( ) <EOL> k = pyGPs . cov . RBF ( ) <EOL> model . setPrior ( mean = m , kernel = k , inducing_points = self . uc ) <EOL> model . setOptimizer ( "<STR_LIT>" , num_restarts = <NUM_LIT:10> ) <EOL> model . optimize ( self . xc , self . yc ) <EOL> model . predict ( self . zc ) <EOL> self . checkClassificationOutput ( model ) <EOL> model = pyGPs . GPC_FITC ( ) <EOL> m = pyGPs . mean . Zero ( ) <EOL> k = pyGPs . cov . RBF ( ) <EOL> model . setPrior ( mean = m , kernel = k , inducing_points = self . uc ) <EOL> model . setOptimizer ( "<STR_LIT>" , num_restarts = <NUM_LIT:10> ) <EOL> model . useInference ( "<STR_LIT>" ) <EOL> model . optimize ( self . xc , self . yc ) <EOL> model . predict ( self . zc ) <EOL> self . checkClassificationOutput ( model ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> print ( "<STR_LIT>" ) <EOL> unittest . main ( ) </s>
