fig.delaxes(ax6) plt.tight_layout() plt.savefig("figure.svg") comp.xVals = xVals comp.xLabels = xLabels print(data) plots = list() # give dummy 0 vals for dist and target AUC for currLayer, (groups, stats) in enumerate( treeMergeSort(data, comp, [(D0, D1), 0, 0], combGroups=False)): print(groups) rocs = list() for group in groups: rocs.append(genROC(group, D0, D1)) avgROC = avROC(rocs) xLabels[currLayer] = len(comp) auc, varEstimate, hanleyMcNeil, estimates = stats f.write(''.join([str(val) + ',' for val in stats])) f.write('\n') aucs[currLayer] = auc varEstimates[currLayer] = varEstimate hmnEstimates[currLayer] = np.append( np.full((layers - len(estimates)), np.nan), estimates) compLens[currLayer] = len(comp) for plot in plots: for line in plot: try: line.remove() except ValueError:
roc, mseTheo, mseEmp, empiricROC = next(elo) ax1.plot(x, y, linestyle='--', label='true', lw=3) ax1.plot(empiricROC['x'], empiricROC['y'], linestyle=':', lw=2, label='empirical') ax1.plot(roc['x'], roc['y'], label='predicted') ax1.legend(loc=4) ax1.set_title( f"ELO\n{i+1}, {mseTheo[0]*1000:02.3f}E(-3), {mseEmp[0]*1000:02.3f}E(-3)" ) groups = next(merge) rocs = [] for group in groups: rocs.append(genROC(group, D0, D1)) roc = avROC(rocs) mseTheo, mseEmp, auc = MSE(7.72, 'exponential', zip(*roc)), MSE( 7.72, 'exponential', zip(*roc), zip(empiricROC['x'], empiricROC['y'])) ax2.plot(x, y, linestyle='--', label='true', lw=3) ax2.plot(empiricROC['x'], empiricROC['y'], linestyle=':', lw=2, label='empirical') ax2.plot(*roc, label='predicted') ax2.legend() ax2.set_title(
matplotlib.use("QT4Agg") import matplotlib.pyplot as plt from DylMath import genROC, avROC, auc data, D0, D1 = continuousScale(16, 16) comp: Comparator = Comparator(data, rand=True) comp.genRand(len(D0), len(D1), 7.72, "exponential") comps: list = list() rocs: list = list() overlapping: bool = argv[2] == "True" if len(argv) == 3 else True for groups in treeMergeSort(data, comp, combGroups=False): rocs.append(list()) comps.append(len(comp)) arr: list = [] for group in groups: arr.extend(group) rocs[-1].append(genROC(group, D0, D1)) rocs[-1]: tuple = list(zip(*avROC(rocs[-1]))) #rocs[-1].reverse() #print(comp.kendalltau(arr), MSE(7.72, rocs[-1], comp.empiricROC())) if not overlapping: rows: int = int(np.ceil(np.sqrt(len(rocs)))) cols: int = int(np.ceil(len(rocs) / rows)) fig, axes = plt.subplots(rows, cols, sharex=True, sharey=True, num="plots") fig.suptitle("ROC Curves") for i,ax in enumerate(axes.flat): if i >= len(rocs): continue ax.set_aspect('equal', 'box') ax.set(xlabel="FPF", ylabel="TPF") ax.label_outer() ax.plot((0,1),(0,1),c='red', linestyle=":")