<s> import lxmls . readers . simple_data_set as sds <EOL> import lxmls . classifiers . linear_classifier as lcc <EOL> import lxmls . classifiers . naive_bayes as nbc <EOL> import lxmls . classifiers . perceptron as percc <EOL> import lxmls . classifiers . svm as svmc <EOL> import lxmls . classifiers . mira as mirac <EOL> import lxmls . classifiers . max_ent_batch as mec_batch <EOL> import lxmls . classifiers . max_ent_online as mec_online <EOL> def run_all_classifiers ( dataset ) : <EOL> fig , axis = dataset . plot_data ( ) <EOL> print "<STR_LIT>" <EOL> nb = nbc . NaiveBayes ( ) <EOL> params_nb = nb . train ( dataset . train_X , dataset . train_y ) <EOL> print params_nb . reshape ( - <NUM_LIT:1> ) <EOL> predict = nb . test ( dataset . train_X , params_nb ) <EOL> evaluation = nb . evaluate ( predict , dataset . train_y ) <EOL> predict2 = nb . test ( dataset . test_X , params_nb ) <EOL> evaluation2 = nb . evaluate ( predict2 , dataset . test_y ) <EOL> print "<STR_LIT>" % ( evaluation , evaluation2 ) <EOL> fig , axis = dataset . add_line ( fig , axis , params_nb , "<STR_LIT>" , "<STR_LIT>" ) <EOL> print "<STR_LIT>" <EOL> perc = percc . Perceptron ( ) <EOL> params_perc = perc . train ( dataset . train_X , dataset . train_y ) <EOL> print params_perc . reshape ( - <NUM_LIT:1> ) <EOL> predict = perc . test ( dataset . train_X , params_perc ) <EOL> evaluation = perc . evaluate ( predict , dataset . train_y ) <EOL> predict2 = perc . test ( dataset . test_X , params_perc ) <EOL> evaluation2 = perc . evaluate ( predict2 , dataset . test_y ) <EOL> print "<STR_LIT>" % ( evaluation , evaluation2 ) <EOL> fig , axis = dataset . add_line ( fig , axis , params_perc , "<STR_LIT>" , "<STR_LIT>" ) <EOL> print "<STR_LIT>" <EOL> me = mec_batch . MaxEnt_batch ( ) <EOL> params_me = me . train ( dataset . train_X , dataset . train_y ) <EOL> print params_me . reshape ( - <NUM_LIT:1> ) <EOL> predict = me . test ( dataset . train_X , params_me ) <EOL> evaluation = me . evaluate ( predict , dataset . train_y ) <EOL> predict2 = me . test ( dataset . test_X , params_me ) <EOL> evaluation2 = me . evaluate ( predict2 , dataset . test_y ) <EOL> print "<STR_LIT>" % ( evaluation , evaluation2 ) <EOL> fig , axis = dataset . add_line ( fig , axis , params_me , "<STR_LIT>" , "<STR_LIT>" ) <EOL> print "<STR_LIT>" <EOL> me_online = mec_online . MaxEnt_online ( ) <EOL> params_me = me_online . train ( dataset . train_X , dataset . train_y ) <EOL> print params_me . reshape ( - <NUM_LIT:1> ) <EOL> predict = me_online . test ( dataset . train_X , params_me ) <EOL> evaluation = me_online . evaluate ( predict , dataset . train_y ) <EOL> predict2 = me_online . test ( dataset . test_X , params_me ) <EOL> evaluation2 = me . evaluate ( predict2 , dataset . test_y ) <EOL> print "<STR_LIT>" % ( evaluation , evaluation2 ) <EOL> fig , axis = dataset . add_line ( fig , axis , params_me , "<STR_LIT>" , "<STR_LIT>" ) <EOL> print "<STR_LIT>" <EOL> mira = mirac . Mira ( ) <EOL> params_mira = mira . train ( dataset . train_X , dataset . train_y ) <EOL> print params_mira . reshape ( - <NUM_LIT:1> ) <EOL> predict = mira . test ( dataset . train_X , params_mira ) <EOL> evaluation = mira . evaluate ( predict , dataset . train_y ) <EOL> predict2 = mira . test ( dataset . test_X , params_mira ) <EOL> evaluation2 = mira . evaluate ( predict2 , dataset . test_y ) <EOL> print "<STR_LIT>" % ( evaluation , evaluation2 ) <EOL> fig , axis = dataset . add_line ( fig , axis , params_mira , "<STR_LIT>" , "<STR_LIT>" ) <EOL> print "<STR_LIT>" <EOL> svm = svmc . SVM ( ) <EOL> params_svm = svm . train ( dataset . train_X , dataset . train_y ) <EOL> print params_svm . reshape ( - <NUM_LIT:1> ) <EOL> predict = svm . test ( dataset . train_X , params_svm ) <EOL> evaluation = svm . evaluate ( predict , dataset . train_y ) <EOL> predict2 = svm . test ( dataset . test_X , params_svm ) <EOL> evaluation2 = svm . evaluate ( predict2 , dataset . test_y ) <EOL> print "<STR_LIT>" % ( evaluation , evaluation2 ) <EOL> fig , axis = dataset . add_line ( fig , axis , params_svm , "<STR_LIT>" , "<STR_LIT>" ) </s>
