def MakePlot(details, final, counts, pickVects, nModels, nTrueActs=-1): if not hasattr(details, 'plotFile') or not details.plotFile: return dataFileName = '%s.dat' % (details.plotFile) outF = open(dataFileName, 'w+') i = 0 while i < len(final) and counts[i] != 0: if nModels > 1: _, sd = Stats.MeanAndDev(pickVects[i]) confInterval = Stats.GetConfidenceInterval(sd, len(pickVects[i]), level=90) outF.write('%d %f %f %d %f\n' % (i + 1, final[i][0] / counts[i], final[i][1] / counts[i], counts[i], confInterval)) else: outF.write('%d %f %f %d\n' % (i + 1, final[i][0] / counts[i], final[i][1] / counts[i], counts[i])) i += 1 outF.close() plotFileName = '%s.gnu' % (details.plotFile) gnuF = open(plotFileName, 'w+') gnuHdr = """# Generated by EnrichPlot.py version: %s set size square 0.7 set xr [0:] set data styl points set ylab 'Num Correct Picks' set xlab 'Num Picks' set grid set nokey set term postscript enh color solid "Helvetica" 16 set term X """ % (__VERSION_STRING) print(gnuHdr, file=gnuF) if nTrueActs > 0: print('set yr [0:%d]' % nTrueActs, file=gnuF) print('plot x with lines', file=gnuF) if nModels > 1: everyGap = i / 20 print('replot "%s" using 1:2 with lines,' % (dataFileName), end='', file=gnuF) print('"%s" every %d using 1:2:5 with yerrorbars' % (dataFileName, everyGap), file=gnuF) else: print('replot "%s" with points' % (dataFileName), file=gnuF) gnuF.close() if hasattr(details, 'showPlot') and details.showPlot: try: from Gnuplot import Gnuplot p = Gnuplot() p('load "%s"' % (plotFileName)) input('press return to continue...\n') except Exception: import traceback traceback.print_exc()
nModels, nTrueActs=nTrueActives) else: if nModels > 1: print( '#Index\tAvg_num_correct\tConf90Pct\tAvg_num_picked\tNum_picks\tlast_selection' ) else: print( '#Index\tAvg_num_correct\tAvg_num_picked\tNum_picks\tlast_selection' ) i = 0 while i < nPts and counts[i] != 0: if nModels > 1: mean, sd = Stats.MeanAndDev(pickVects[i]) confInterval = Stats.GetConfidenceInterval(sd, len(pickVects[i]), level=90) print('%d\t%f\t%f\t%f\t%d\t%s' % (i + 1, final[i][0] / counts[i], confInterval, final[i][1] / counts[i], counts[i], str(selPts[i]))) else: print('%d\t%f\t%f\t%d\t%s' % (i + 1, final[i][0] / counts[i], final[i][1] / counts[i], counts[i], str(selPts[i]))) i += 1 mean, sd = Stats.MeanAndDev(halfwayPts) print('Halfway point: %.2f(%.2f)' % (mean, sd))