<s> import unittest <EOL> from nose . tools import ( assert_equal , assert_raises , assert_in , assert_not_in ) <EOL> import numpy <EOL> from scipy . stats import randint , uniform <EOL> from sklearn . grid_search import GridSearchCV , RandomizedSearchCV <EOL> from sklearn . cross_validation import cross_val_score <EOL> from sklearn . ensemble import VotingClassifier <EOL> from sknn . mlp import Regressor as MLPR , Classifier as MLPC <EOL> from sknn . mlp import Layer as L <EOL> class TestGridSearchRegressor ( unittest . TestCase ) : <EOL> __estimator__ = MLPR <EOL> __output__ = "<STR_LIT>" <EOL> def setUp ( self ) : <EOL> self . a_in = numpy . random . uniform ( <NUM_LIT:0.0> , <NUM_LIT:1.0> , ( <NUM_LIT:64> , <NUM_LIT:16> ) ) <EOL> self . a_out = numpy . zeros ( ( <NUM_LIT:64> , <NUM_LIT:1> ) ) <EOL> def test_GridGlobalParams ( self ) : <EOL> clf = GridSearchCV ( <EOL> self . __estimator__ ( layers = [ L ( self . __output__ ) ] , n_iter = <NUM_LIT:1> ) , <EOL> param_grid = { '<STR_LIT>' : [ <NUM_LIT> , <NUM_LIT> ] } ) <EOL> clf . fit ( self . a_in , self . a_out ) <EOL> def test_GridLayerParams ( self ) : <EOL> clf = GridSearchCV ( <EOL> self . __estimator__ ( layers = [ L ( "<STR_LIT>" , units = <NUM_LIT:12> ) , L ( self . __output__ ) ] , n_iter = <NUM_LIT:1> ) , <EOL> param_grid = { '<STR_LIT>' : [ <NUM_LIT:4> , <NUM_LIT:8> , <NUM_LIT:12> ] } ) <EOL> clf . fit ( self . a_in , self . a_out ) <EOL> def test_RandomGlobalParams ( self ) : <EOL> clf = RandomizedSearchCV ( <EOL> self . __estimator__ ( layers = [ L ( "<STR_LIT>" ) ] , n_iter = <NUM_LIT:1> ) , <EOL> param_distributions = { '<STR_LIT>' : uniform ( <NUM_LIT> , <NUM_LIT> ) } , <EOL> n_iter = <NUM_LIT:2> ) <EOL> clf . fit ( self . a_in , self . a_out ) <EOL> def test_RandomLayerParams ( self ) : <EOL> clf = RandomizedSearchCV ( <EOL> self . __estimator__ ( layers = [ L ( "<STR_LIT>" , units = <NUM_LIT:12> ) , L ( self . __output__ ) ] , n_iter = <NUM_LIT:1> ) , <EOL> param_distributions = { '<STR_LIT>' : randint ( <NUM_LIT:4> , <NUM_LIT:12> ) } , <EOL> n_iter = <NUM_LIT:2> ) <EOL> clf . fit ( self . a_in , self . a_out ) <EOL> def test_RandomMultipleJobs ( self ) : <EOL> clf = RandomizedSearchCV ( <EOL> self . __estimator__ ( layers = [ L ( "<STR_LIT>" , units = <NUM_LIT:12> ) , L ( self . __output__ ) ] , n_iter = <NUM_LIT:1> ) , <EOL> param_distributions = { '<STR_LIT>' : randint ( <NUM_LIT:4> , <NUM_LIT:12> ) } , <EOL> n_iter = <NUM_LIT:4> , n_jobs = <NUM_LIT:4> ) <EOL> clf . fit ( self . a_in , self . a_out ) <EOL> class TestGridSearchClassifier ( TestGridSearchRegressor ) : <EOL> __estimator__ = MLPC <EOL> __output__ = "<STR_LIT>" <EOL> def setUp ( self ) : <EOL> self . a_in = numpy . random . uniform ( <NUM_LIT:0.0> , <NUM_LIT:1.0> , ( <NUM_LIT:64> , <NUM_LIT:16> ) ) <EOL> self . a_out = numpy . random . randint ( <NUM_LIT:0> , <NUM_LIT:4> , ( <NUM_LIT:64> , ) ) <EOL> class TestCrossValidation ( unittest . TestCase ) : <EOL> def test_Regressor ( self ) : <EOL> a_in = numpy . random . uniform ( <NUM_LIT:0.0> , <NUM_LIT:1.0> , ( <NUM_LIT:64> , <NUM_LIT:16> ) ) <EOL> a_out = numpy . zeros ( ( <NUM_LIT:64> , <NUM_LIT:1> ) ) <EOL> cross_val_score ( MLPR ( layers = [ L ( "<STR_LIT>" ) ] , n_iter = <NUM_LIT:1> ) , a_in , a_out , cv = <NUM_LIT:5> ) <EOL> def test_Classifier ( self ) : <EOL> a_in = numpy . random . uniform ( <NUM_LIT:0.0> , <NUM_LIT:1.0> , ( <NUM_LIT:64> , <NUM_LIT:16> ) ) <EOL> a_out = numpy . random . randint ( <NUM_LIT:0> , <NUM_LIT:4> , ( <NUM_LIT:64> , ) ) <EOL> cross_val_score ( MLPC ( layers = [ L ( "<STR_LIT>" ) ] , n_iter = <NUM_LIT:1> ) , a_in , a_out , cv = <NUM_LIT:5> ) <EOL> class TestVotingEnsemble ( unittest . TestCase ) : <EOL> def test_SingleVote ( self ) : <EOL> a_in , a_out = numpy . random . uniform ( <NUM_LIT:0.0> , <NUM_LIT:1.0> , ( <NUM_LIT:64> , <NUM_LIT:16> ) ) , numpy . zeros ( ( <NUM_LIT:64> , ) ) <EOL> vc = VotingClassifier ( [ ( '<STR_LIT>' , MLPC ( layers = [ L ( "<STR_LIT>" ) ] , n_iter = <NUM_LIT:1> ) ) ] ) <EOL> vc . fit ( a_in , a_out ) <EOL> vc . predict ( a_in ) </s>
