output = open(args.output + "/" + blog + '_PREw_predTime.pkl', 'wb') cPickle.dump(prec_curveWA, output) output = open(args.output + "/" + blog + '_RECw_predTime.pkl', 'wb') cPickle.dump(rec_curveWA, output) output = open(args.output + "/" + blog + '_F1Mw_predTime.pkl', 'wb') cPickle.dump(f1_curveWA, output) #Plot results #print acc_curve #xlb,dat_crv,lb_crv=plOT.getScoresCurves(acc_curve,nyrs) #print xlb #print dat_crv xlbWA, dat_crvWA, lb_crvWA = plOT.getScoresCurves(acc_curveWA, nyrs) legends = ["Years", "Accuracy", "Accuracy of predictions over time"] #plOT.plotBehaviorN(xlb,dat_crv,lb_crv,legends,"../plots/"+blog+"_acc_svc_ovrtm.png") plOT.plotBehaviorN(xlbWA, dat_crvWA, lb_crvWA, legends, "../plots/" + blog + "_accWA_svc_ovrtm.png") #xlb,dat_crv,lb_crv=plOT.getScoresCurves(prec_curve,nyrs) xlbWA, dat_crvWA, lb_crvWA = plOT.getScoresCurves(prec_curveWA, nyrs) legends = ["Years", "Precision", "Precision of predictions over time"] #plOT.plotBehaviorN(xlb,dat_crv,lb_crv,legends,"../plots/"+blog+"_prec_svc_ovrtm.png") plOT.plotBehaviorN(xlbWA, dat_crvWA, lb_crvWA, legends, "../plots/" + blog + "_precWA_svc_ovrtm.png") #xlb,dat_crv,lb_crv=plOT.getScoresCurves(rec_curve,nyrs) xlbWA, dat_crvWA, lb_crvWA = plOT.getScoresCurves(rec_curveWA, nyrs) legends = ["Years", "recall", "Recall of predictions over time"] #plOT.plotBehaviorN(xlb,dat_crv,lb_crv,legends,"../plots/"+blog+"_rec_svc_ovrtm.png") plOT.plotBehaviorN(xlbWA, dat_crvWA, lb_crvWA, legends, "../plots/" + blog + "_recWA_svc_ovrtm.png")
#cPickle.dump(acc_curveWA, output) #output = open(args.output+"/"+blog+'_PREw_predTime.pkl', 'wb') #cPickle.dump(prec_curveWA, output) #output = open(args.output+"/"+blog+'_RECw_predTime.pkl', 'wb') #cPickle.dump(rec_curveWA, output) #output = open(args.output+"/"+blog+'_F1Mw_predTime.pkl', 'wb') #cPickle.dump(f1_curveWA, output) #Plot results #print acc_curve xlb, dat_crv, lb_crv = plOT.getScoresCurves(acc_curve, nyrs) #print xlb #print dat_crv #xlbWA,dat_crvWA,lb_crvWA=plOT.getScoresCurves(acc_curveWA,nyrs) legends = ["Years", "Accuracy", "Accuracy of predictions over time"] plOT.plotBehaviorN(xlb, dat_crv, lb_crv, legends, "../plots/" + blog + "_acc_svc_ovrtm.png") #plOT.plotBehaviorN(xlbWA,dat_crvWA,lb_crv,legends,"../plots/"+blog+"_accWA_svc_ovrtm.png") xlb, dat_crv, lb_crv = plOT.getScoresCurves(prec_curve, nyrs) #xlbWA,dat_crvWA,lb_crvWA=plOT.getScoresCurves(prec_curveWA,nyrs) legends = ["Years", "Precision", "Precision of predictions over time"] plOT.plotBehaviorN(xlb, dat_crv, lb_crv, legends, "../plots/" + blog + "_prec_svc_ovrtm.png") #plOT.plotBehaviorN(xlbWA,dat_crvWA,lb_crv,legends,"../plots/"+blog+"_precWA_svc_ovrtm.png") xlb, dat_crv, lb_crv = plOT.getScoresCurves(rec_curve, nyrs) #xlbWA,dat_crvWA,lb_crvWA=plOT.getScoresCurves(rec_curveWA,nyrs) legends = ["Years", "recall", "Recall of predictions over time"] plOT.plotBehaviorN(xlb, dat_crv, lb_crv, legends, "../plots/" + blog + "_rec_svc_ovrtm.png") #plOT.plotBehaviorN(xlbWA,dat_crvWA,lb_crv,legends,"../plots/"+blog+"_recWA_svc_ovrtm.png")
cPickle.dump(acc_curveWA, output) output = open(resDirSV + blog + '_PREw_predTime.pkl', 'wb') cPickle.dump(prec_curveWA, output) output = open(resDirSV + blog + '_RECw_predTime.pkl', 'wb') cPickle.dump(rec_curveWA, output) output = open(resDirSV + blog + '_F1Mw_predTime.pkl', 'wb') cPickle.dump(f1_curveWA, output) #Plot results #print acc_curve xlb, dat_crv, lb_crv = plOT.getScoresCurves(acc_curve, nyrs) #print xlb #print dat_crv xlbWA, dat_crvWA, lb_crvWA = plOT.getScoresCurves(acc_curveWA, nyrs) legends = ["Years", "Accuracy", "Accuracy of predictions over time"] plOT.plotBehaviorN(xlb, dat_crv, lb_crv, legends, plotsDir + blog + "_acc_svc_ovrtm.png") plOT.plotBehaviorN(xlbWA, dat_crvWA, lb_crv, legends, plotsDir + blog + "_accWA_svc_ovrtm.png") xlb, dat_crv, lb_crv = plOT.getScoresCurves(prec_curve, nyrs) xlbWA, dat_crvWA, lb_crvWA = plOT.getScoresCurves(prec_curveWA, nyrs) legends = ["Years", "Precision", "Precision of predictions over time"] plOT.plotBehaviorN(xlb, dat_crv, lb_crv, legends, plotsDir + blog + "_prec_svc_ovrtm.png") plOT.plotBehaviorN(xlbWA, dat_crvWA, lb_crv, legends, plotsDir + blog + "_precWA_svc_ovrtm.png") xlb, dat_crv, lb_crv = plOT.getScoresCurves(rec_curve, nyrs) xlbWA, dat_crvWA, lb_crvWA = plOT.getScoresCurves(rec_curveWA, nyrs) legends = ["Years", "recall", "Recall of predictions over time"] plOT.plotBehaviorN(xlb, dat_crv, lb_crv, legends,
#a.append(0) g += 2 else: a.append(float(y)) data.append(a) else: for y in dat: if y == "": #a.append(0) g += 2 else: a.append(int(y)) data.append(a) t += 1 return data path = "../comparative/" #allfiles=os.listdir("latestTAL/predOT-master/results/shots/predictions") allfiles = next(os.walk(path))[2] lb_crv = ["lastYr", "eachYr", "eachYrW"] for blf in allfiles: prplt = getDataToPlot(path + blf) print prplt blname = blf.split('.')[0] legends = [ "Years", "F1-measure", "Comparative of approaches for re-training over time" ] plOT.plotBehaviorN(prplt[0], prplt[1:], lb_crv, legends, path + "plots/" + blname + "_f1_3approach.png")
# -*- coding: utf-8 -*- """ Created on Sat Jan 27 20:53:28 2018 @author: ivan """ import cPickle import plotOverTime as plOT fileIn="../testing/test_correct_nologs/results/coupleofpixels_F1M_predTime.pkl" output = open(fileIn) restoredVar=cPickle.load(output) print type(restoredVar) #nyrs=[2009,2010,2011,2012,2013,2014,2015] nyrs=4 xlb,dat_crv,lb_crv=plOT.getScoresCurves(restoredVar,nyrs) print dat_crv print xlb #xlbWA,dat_crvWA,lb_crvWA=plOT.getScoresCurves(f1_curveWA,nyrs) legends=["Years","f1-measure","F1-measure of predictions over time"] plOT.plotBehaviorN(xlb,dat_crv,lb_crv,legends) #plOT.plotBehaviorN(xlb,dat_crv,lb_crv,legends,"../plots/"+blog+"_f1_svc_ovrtm.png") #plOT.plotBehaviorN(xlbWA,dat_crvWA,lb_crv,legends,"../plots/"+blog+"_f1WA_svc_ovrtm.png")
if tictac: print datetime.now() - startTime if v: print "-------------------------------------------------------" # break #Plot results #a=[[0.6,0.8,1,0.32],[0.47,0.5,.21,0.9]] Sco_crv, Yr_crv = plOT.getScoresCurve(acc_curve) Sco_crvWA, Yr_crvWA = plOT.getScoresCurve(acc_curveWA) curvesToplot = [Sco_crv, Sco_crvWA] #b=[2007,2008,2009,2010] #c=[2007,2008] #x=["x label","y label","title"] #plotBehaviorN(b,a,c,x,"sample.png") plOT.plotBehaviorN(b, curvesToplot, c, x, "sample.png") #save results into files output = open(args.output + "/" + blog + '_ACC_predTime.pkl', 'wb') cPickle.dump(acc_curve, output) output = open(args.output + "/" + blog + '_PRE_predTime.pkl', 'wb') cPickle.dump(prec_curve, output) output = open(args.output + "/" + blog + '_REC_predTime.pkl', 'wb') cPickle.dump(rec_curve, output) output = open(args.output + "/" + blog + '_F1M_predTime.pkl', 'wb') cPickle.dump(f1_curve, output) output = open(args.output + "/" + blog + '_ACCw_predTime.pkl', 'wb') cPickle.dump(acc_curveWA, output) output = open(args.output + "/" + blog + '_PREw_predTime.pkl', 'wb') cPickle.dump(prec_curveWA, output)
#allfiles=os.listdir("latestTAL/predOT-master/results/shots/predictions") #allfiles=next(os.walk(path))[2] #fileIn="../testing/test_correct_nologs/results/coupleofpixels_F1M_predTime.pkl" curBlog=flog.Blog(args.blog) #first_year=earliest year of the data first_year=curBlog.getBlogOriginDate().year #last_year=latest year of the data last_year=curBlog.getBlogLastDate().year nyrs=last_year-first_year for fl in next(os.walk(path))[2]: fileIn=fl output = open(fileIn) restoredVar=cPickle.load(output) fnamep=fileIn.split('_') #print type(restoredVar) #nyrs=[2009,2010,2011,2012,2013,2014,2015] #nyrs=4 xlb,dat_crv,lb_crv=plOT.getScoresCurves(restoredVar,nyrs) #print dat_crv #print xlb #xlbWA,dat_crvWA,lb_crvWA=plOT.getScoresCurves(f1_curveWA,nyrs) operMes=resultType(fnamep[1]) legends=["Years",operMes,operMes+" of predictions over time"] plOT.plotBehaviorN(xlb,dat_crv,lb_crv,legends,"../plots/"+args.blog+"_"+fnamep[1]+"_svc_ovrtm.png") #plOT.plotBehaviorN(xlb,dat_crv,lb_crv,legends,"../plots/"+blog+"_f1_svc_ovrtm.png") #plOT.plotBehaviorN(xlbWA,dat_crvWA,lb_crv,legends,"../plots/"+blog+"_f1WA_svc_ovrtm.png")