list1.append(lookupcat[cnt]+'_'+j) list2.append(i[j]) indices = [i[0] for i in sorted(enumerate(list2), key=lambda x:x[1])] indices.reverse() for i in range(nTop): list3.append(list1[indices[i]]) list4.append(list2[indices[i]]) for i in range(nTop): writer.writerow([str(i),list3[i],list4[i]]) outf.close() print 'done' #making histograms here val_table=kmodule.make_value_table('cookies_train.csv') indi_hist=kmodule.make_histograms(val_table) #female histogram load val_table=kmodule.make_value_table('cookies_gender_female.csv') hist2=kmodule.make_histograms(val_table) #male histogram load val_table=kmodule.make_value_table('cookies_gender_male.csv') hist1=kmodule.make_histograms(val_table) #make lifta tables for gender male_lifts, female_lifts=[],[] for i in range(len(indi_hist)): male_lifts.append(dict()) female_lifts.append(dict()) for i in range(len(indi_hist)): for j in indi_hist[i]:
p6=plot(recall,precision, 'ro') # legend([p2], ['ROC with AUC ' + aucstr + '.png']) savefig('Recall-Precision with ' + aucstr + '.png') if shouldShow: show() print 'done plotting Recall-Precision' def saveFalloutsRecallsAndPrecisionsToFile(fallouts, recalls, precisions, aucstr = ''): print 'saveFalloutsRecallsAndPrecisionsToFile' data=np.array([fallouts,recalls,precisions]) np.savetxt('FalloutsRecallsAndPrecisionsWith ' + aucstr + '.csv', data, delimiter=',') print 'done saveFalloutsRecallsAndPrecisionsToFile' #making histograms here val_table=kmodule.make_value_table('cookies_train.csv') indi_hist=kmodule.make_histograms(val_table) #print indi_hist print '<-- full list of indi histograms' labelfile=open('cookie_table_of_labels.csv','r') all_labels = labelfile.readlines() labelfile.close() gender_labels=all_labels[1].split(',') gender_labels[-1]=gender_labels[-1][:-2] #gender_labels=gender_labels[:-1] cond_hists=dict(zip(gender_labels,range(len(gender_labels)))) for i in gender_labels: val_table=kmodule.make_value_table('cookies_gender_'+i+'.csv') cond_hists[i]=kmodule.make_histograms(val_table) #print cond_hists[i] print '<--histograms for '+i