<s> import sys , pdb <EOL> sys . path . append ( "<STR_LIT:.>" ) <EOL> import lxmls . readers . simple_data_set as sds <EOL> import lxmls . readers . sentiment_reader as srs <EOL> import lxmls . classifiers . linear_classifier as lcc <EOL> import lxmls . classifiers . perceptron as percc <EOL> import lxmls . classifiers . mira as mirac <EOL> import lxmls . classifiers . gaussian_naive_bayes as gnbc <EOL> import lxmls . classifiers . multinomial_naive_bayes as mnb <EOL> reload ( mnb ) <EOL> import lxmls . classifiers . max_ent_batch as mebc <EOL> import lxmls . classifiers . max_ent_online as meoc <EOL> import lxmls . classifiers . svm as svmc <EOL> import lxmls . classifiers . naive_bayes as nb <EOL> import lxmls . run_all_classifiers as run_all_c <EOL> sd = sds . SimpleDataSet ( nr_examples = <NUM_LIT:100> , <EOL> g1 = [ [ - <NUM_LIT:1> , - <NUM_LIT:1> ] , <NUM_LIT:1> ] , <EOL> g2 = [ [ <NUM_LIT:1> , <NUM_LIT:1> ] , <NUM_LIT:1> ] , <EOL> balance = <NUM_LIT:0.5> , <EOL> split = [ <NUM_LIT:0.5> , <NUM_LIT:0> , <NUM_LIT:0.5> ] ) <EOL> fig , axis = sd . plot_data ( ) <EOL> gnb = gnbc . GaussianNaiveBayes ( ) <EOL> params_nb_sd = gnb . train ( sd . train_X , sd . train_y ) <EOL> y_pred_train = gnb . test ( sd . train_X , params_nb_sd ) <EOL> acc_train = gnb . evaluate ( sd . train_y , y_pred_train ) <EOL> y_pred_test = gnb . test ( sd . test_X , params_nb_sd ) <EOL> acc_test = gnb . evaluate ( sd . test_y , y_pred_test ) <EOL> fig , axis = sd . add_line ( fig , axis , params_nb_sd , "<STR_LIT>" , "<STR_LIT>" ) <EOL> print "<STR_LIT>" % ( acc_train , acc_test ) <EOL> print <EOL> perc = percc . Perceptron ( ) <EOL> params_perc_sd = perc . train ( sd . train_X , sd . train_y ) <EOL> y_pred_train = perc . test ( sd . train_X , params_perc_sd ) <EOL> acc_train = perc . evaluate ( sd . train_y , y_pred_train ) <EOL> y_pred_test = perc . test ( sd . test_X , params_perc_sd ) <EOL> acc_test = perc . evaluate ( sd . test_y , y_pred_test ) <EOL> fig , axis = sd . add_line ( fig , axis , params_perc_sd , "<STR_LIT>" , "<STR_LIT>" ) <EOL> print "<STR_LIT>" % ( acc_train , acc_test ) <EOL> print <EOL> mira = mirac . Mira ( ) <EOL> params_mira_sd = mira . train ( sd . train_X , sd . train_y ) <EOL> y_pred_train = mira . test ( sd . train_X , params_mira_sd ) <EOL> acc_train = mira . evaluate ( sd . train_y , y_pred_train ) <EOL> y_pred_test = mira . test ( sd . test_X , params_mira_sd ) <EOL> acc_test = mira . evaluate ( sd . test_y , y_pred_test ) <EOL> fig , axis = sd . add_line ( fig , axis , params_mira_sd , "<STR_LIT>" , "<STR_LIT>" ) <EOL> print "<STR_LIT>" % ( acc_train , acc_test ) <EOL> print <EOL> me_lbfgs = mebc . MaxEnt_batch ( ) <EOL> params_meb_sd = me_lbfgs . train ( sd . train_X , sd . train_y ) <EOL> y_pred_train = me_lbfgs . test ( sd . train_X , params_meb_sd ) <EOL> acc_train = me_lbfgs . evaluate ( sd . train_y , y_pred_train ) <EOL> y_pred_test = me_lbfgs . test ( sd . test_X , params_meb_sd ) <EOL> acc_test = me_lbfgs . evaluate ( sd . test_y , y_pred_test ) <EOL> fig , axis = sd . add_line ( fig , axis , params_meb_sd , "<STR_LIT>" , "<STR_LIT>" ) <EOL> print "<STR_LIT>" % ( acc_train , acc_test ) <EOL> print <EOL> me_sgd = meoc . MaxEnt_online ( ) <EOL> params_meo_sd = me_sgd . train ( sd . train_X , sd . train_y ) <EOL> y_pred_train = me_sgd . test ( sd . train_X , params_meo_sd ) <EOL> acc_train = me_sgd . evaluate ( sd . train_y , y_pred_train ) <EOL> y_pred_test = me_sgd . test ( sd . test_X , params_meo_sd ) <EOL> acc_test = me_sgd . evaluate ( sd . test_y , y_pred_test ) <EOL> fig , axis = sd . add_line ( fig , axis , params_meo_sd , "<STR_LIT>" , "<STR_LIT>" ) <EOL> print "<STR_LIT>" % ( acc_train , acc_test ) <EOL> print <EOL> svm = svmc . SVM ( ) <EOL> params_svm_sd = svm . train ( sd . train_X , sd . train_y ) <EOL> y_pred_train = svm . test ( sd . train_X , params_svm_sd ) <EOL> acc_train = svm . evaluate ( sd . train_y , y_pred_train ) <EOL> y_pred_test = svm . test ( sd . test_X , params_svm_sd ) <EOL> acc_test = svm . evaluate ( sd . test_y , y_pred_test ) <EOL> fig , axis = sd . add_line ( fig , axis , params_svm_sd , "<STR_LIT>" , "<STR_LIT>" ) <EOL> print "<STR_LIT>" % ( acc_train , acc_test ) <EOL> print <EOL> scr = srs . SentimentCorpus ( "<STR_LIT>" ) <EOL> mnb = mnb . MultinomialNaiveBayes ( ) <EOL> params_nb_sc = mnb . train ( scr . train_X , scr . train_y ) <EOL> y_pred_train = mnb . test ( scr . train_X , params_nb_sc ) <EOL> acc_train = mnb . evaluate ( scr . train_y , y_pred_train ) <EOL> y_pred_test = mnb . test ( scr . test_X , params_nb_sc ) <EOL> acc_test = mnb . evaluate ( scr . test_y , y_pred_test ) <EOL> print "<STR_LIT>" % ( acc_train , acc_test ) <EOL> print <EOL> params_perc_sc = perc . train ( scr . train_X , scr . train_y ) <EOL> y_pred_train = perc . test ( scr . train_X , params_perc_sc ) <EOL> acc_train = perc . evaluate ( scr . train_y , y_pred_train ) <EOL> y_pred_test = perc . test ( scr . test_X , params_perc_sc ) <EOL> acc_test = perc . evaluate ( scr . test_y , y_pred_test ) <EOL> print "<STR_LIT>" % ( acc_train , acc_test ) <EOL> print <EOL> params_mira_sc = mira . train ( scr . train_X , scr . train_y ) <EOL> y_pred_train = mira . test ( scr . train_X , params_mira_sc ) <EOL> acc_train = mira . evaluate ( scr . train_y , y_pred_train ) <EOL> y_pred_test = mira . test ( scr . test_X , params_mira_sc ) <EOL> acc_test = mira . evaluate ( scr . test_y , y_pred_test ) <EOL> print "<STR_LIT>" % ( acc_train , acc_test ) <EOL> print <EOL> params_meb_sc = me_lbfgs . train ( scr . train_X , scr . train_y ) <EOL> y_pred_train = me_lbfgs . test ( scr . train_X , params_meb_sc ) <EOL> acc_train = me_lbfgs . evaluate ( scr . train_y , y_pred_train ) <EOL> y_pred_test = me_lbfgs . test ( scr . test_X , params_meb_sc ) <EOL> acc_test = me_lbfgs . evaluate ( scr . test_y , y_pred_test ) <EOL> print "<STR_LIT>" % ( acc_train , acc_test ) <EOL> print <EOL> params_meo_sc = me_sgd . train ( scr . train_X , scr . train_y ) <EOL> y_pred_train = me_sgd . test ( scr . train_X , params_meo_sc ) <EOL> acc_train = me_sgd . evaluate ( scr . train_y , y_pred_train ) <EOL> y_pred_test = me_sgd . test ( scr . test_X , params_meo_sc ) <EOL> acc_test = me_sgd . evaluate ( scr . test_y , y_pred_test ) <EOL> print "<STR_LIT>" % ( acc_train , acc_test ) <EOL> print <EOL> params_svm_sc = svm . train ( scr . train_X , scr . train_y ) <EOL> y_pred_train = svm . test ( scr . train_X , params_svm_sc ) <EOL> acc_train = svm . evaluate ( scr . train_y , y_pred_train ) <EOL> y_pred_test = svm . test ( scr . test_X , params_svm_sc ) <EOL> acc_test = svm . evaluate ( scr . test_y , y_pred_test ) <EOL> print "<STR_LIT>" % ( acc_train , acc_test ) <EOL> print </s>
