<s> """<STR_LIT>""" <EOL> import numpy as np <EOL> import pylab as pl <EOL> import gc <EOL> from datetime import datetime <EOL> scikit_classifier_results = [ ] <EOL> scikit_regressor_results = [ ] <EOL> mu_second = <NUM_LIT:0.0> + <NUM_LIT:10> ** <NUM_LIT:6> <EOL> def bench_scikit_tree_classifier ( X , Y ) : <EOL> """<STR_LIT>""" <EOL> from sklearn . tree import DecisionTreeClassifier <EOL> gc . collect ( ) <EOL> tstart = datetime . now ( ) <EOL> clf = DecisionTreeClassifier ( ) <EOL> clf . fit ( X , Y ) . predict ( X ) <EOL> delta = ( datetime . now ( ) - tstart ) <EOL> scikit_classifier_results . append ( <EOL> delta . seconds + delta . microseconds / mu_second ) <EOL> def bench_scikit_tree_regressor ( X , Y ) : <EOL> """<STR_LIT>""" <EOL> from sklearn . tree import DecisionTreeRegressor <EOL> gc . collect ( ) <EOL> tstart = datetime . now ( ) <EOL> clf = DecisionTreeRegressor ( ) <EOL> clf . fit ( X , Y ) . predict ( X ) <EOL> delta = ( datetime . now ( ) - tstart ) <EOL> scikit_regressor_results . append ( <EOL> delta . seconds + delta . microseconds / mu_second ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' ) <EOL> n = <NUM_LIT:10> <EOL> step = <NUM_LIT> <EOL> n_samples = <NUM_LIT> <EOL> dim = <NUM_LIT:10> <EOL> n_classes = <NUM_LIT:10> <EOL> for i in range ( n ) : <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' % ( i , n ) ) <EOL> print ( '<STR_LIT>' ) <EOL> n_samples += step <EOL> X = np . random . randn ( n_samples , dim ) <EOL> Y = np . random . randint ( <NUM_LIT:0> , n_classes , ( n_samples , ) ) <EOL> bench_scikit_tree_classifier ( X , Y ) <EOL> Y = np . random . randn ( n_samples ) <EOL> bench_scikit_tree_regressor ( X , Y ) <EOL> xx = range ( <NUM_LIT:0> , n * step , step ) <EOL> pl . figure ( '<STR_LIT>' ) <EOL> pl . subplot ( <NUM_LIT> ) <EOL> pl . title ( '<STR_LIT>' ) <EOL> pl . plot ( xx , scikit_classifier_results , '<STR_LIT>' , label = '<STR_LIT>' ) <EOL> pl . plot ( xx , scikit_regressor_results , '<STR_LIT>' , label = '<STR_LIT>' ) <EOL> pl . legend ( loc = '<STR_LIT>' ) <EOL> pl . xlabel ( '<STR_LIT>' ) <EOL> pl . ylabel ( '<STR_LIT>' ) <EOL> scikit_classifier_results = [ ] <EOL> scikit_regressor_results = [ ] <EOL> n = <NUM_LIT:10> <EOL> step = <NUM_LIT> <EOL> start_dim = <NUM_LIT> <EOL> n_classes = <NUM_LIT:10> <EOL> dim = start_dim <EOL> for i in range ( <NUM_LIT:0> , n ) : <EOL> print ( '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' % ( i , n ) ) <EOL> print ( '<STR_LIT>' ) <EOL> dim += step <EOL> X = np . random . randn ( <NUM_LIT:100> , dim ) <EOL> Y = np . random . randint ( <NUM_LIT:0> , n_classes , ( <NUM_LIT:100> , ) ) <EOL> bench_scikit_tree_classifier ( X , Y ) <EOL> Y = np . random . randn ( <NUM_LIT:100> ) <EOL> bench_scikit_tree_regressor ( X , Y ) <EOL> xx = np . arange ( start_dim , start_dim + n * step , step ) <EOL> pl . subplot ( <NUM_LIT> ) <EOL> pl . title ( '<STR_LIT>' ) <EOL> pl . plot ( xx , scikit_classifier_results , '<STR_LIT>' , label = '<STR_LIT>' ) <EOL> pl . plot ( xx , scikit_regressor_results , '<STR_LIT>' , label = '<STR_LIT>' ) <EOL> pl . legend ( loc = '<STR_LIT>' ) <EOL> pl . xlabel ( '<STR_LIT>' ) <EOL> pl . ylabel ( '<STR_LIT>' ) <EOL> pl . axis ( '<STR_LIT>' ) <EOL> pl . show ( ) </s>
