1414
1515from sklearn .metrics import confusion_matrix
1616
17- from utils import plot_roc , plot_confusion_matrix , GENRE_LIST
17+ from utils import plot_roc , plot_confusion_matrix , GENRE_LIST , TEST_DIR
1818
1919from ceps import read_ceps
2020
21- TEST_DIR = "/media/sf_P/pymlbook-data/09-genre-class/private"
2221
2322genre_list = GENRE_LIST
2423
@@ -83,7 +82,7 @@ def train_model(clf_factory, X, Y, name, plot=False):
8382
8483 if plot :
8584 for label in labels :
86- print "Plotting" , genre_list [label ]
85+ print ( "Plotting %s" % genre_list [label ])
8786 scores_to_sort = roc_scores [label ]
8887 median = np .argsort (scores_to_sort )[len (scores_to_sort ) / 2 ]
8988
@@ -94,7 +93,7 @@ def train_model(clf_factory, X, Y, name, plot=False):
9493 all_pr_scores = np .asarray (pr_scores .values ()).flatten ()
9594 summary = (np .mean (scores ), np .std (scores ),
9695 np .mean (all_pr_scores ), np .std (all_pr_scores ))
97- print "%.3f\t %.3f\t %.3f\t %.3f\t " % summary
96+ print ( "%.3f\t %.3f\t %.3f\t %.3f\t " % summary )
9897
9998 return np .mean (train_errors ), np .mean (test_errors ), np .asarray (cms )
10099
@@ -115,7 +114,5 @@ def create_model():
115114 cm_avg = np .mean (cms , axis = 0 )
116115 cm_norm = cm_avg / np .sum (cm_avg , axis = 0 )
117116
118- print cm_norm
119-
120117 plot_confusion_matrix (cm_norm , genre_list , "ceps" ,
121118 "Confusion matrix of a CEPS based classifier" )
0 commit comments