# get vertex indices of labelled/unlabelled nodes TrIdx = sorted(np.take(latIdx, tr_i)) TstIdx = sorted(np.take(latIdx, tst_i)) # get vertex coordinates TrCoord = [vertices[i] for i in TrIdx] TstCoord = [vertices[i] for i in TstIdx] # get mapLAT signal values TrVal = [mapLAT[i] for i in TrIdx] TstVal = [mapLAT[i] for i in TstIdx] """ MAGIC-LAT estimate """ latEst = magicLAT(vertices, faces, TrIdx, TrCoord, TrVal, EDGE_THRESHOLD) magicDE = metrics.deltaE(TstVal, latEst[TstIdx], MINLAT, MAXLAT) x.append(m) y.append(magicDE) if magicDE > maxDE: maxDE = magicDE ymax = math.ceil(magicDE / 10) * 10 with open(meanFile, 'a') as fid: fid.write('\n') fid.write('{:<20}{:<20.6f}'.format(m, magicDE)) verPoints = Points(TrCoord, r=5).cmap('rainbow_r', TrVal, vmin=MINLAT, vmax=MAXLAT).addScalarBar() estPoints = Points(vertices, r=5).cmap('rainbow_r',
ablFile=ablFile) """ Error metrics """ if verbose: print('\tComputing metrics...') nmse = metrics.calcNMSE(TstVal, latEst[TstIdx]) nmseGPR = metrics.calcNMSE(TstVal, latEstGPR[TstIdx]) nmsequLATi = metrics.calcNMSE(TstVal, latEstquLATi[TstIdx]) mae = metrics.calcMAE(TstVal, latEst[TstIdx]) maeGPR = metrics.calcMAE(TstVal, latEstGPR[TstIdx]) maequLATi = metrics.calcMAE(TstVal, latEstquLATi[TstIdx]) dE = metrics.deltaE(TstVal, latEst[TstIdx], MINLAT, MAXLAT) dEGPR = metrics.deltaE(TstVal, latEstGPR[TstIdx], MINLAT, MAXLAT) dEquLATi = metrics.deltaE(TstVal, latEstquLATi[TstIdx], MINLAT, MAXLAT) if verbose: print('\tWriting to file...') with open(os.path.join(outSubDir, 'metrics.txt'), 'w') as fid: fid.write(nm + '\n\n') fid.write('{:<20}{:g}\n'.format('n', n)) fid.write('{:<20}{:g}/{:g}\n'.format('m', NUM_TRAIN_SAMPS, M)) fid.write('{:<20}{:g}\n\n'.format('anomalous', numPtsIgnored)) fid.write('{:<20}{:<20}{:<20}{:<20}\n\n'.format('Metric', 'MAGIC-LAT', 'GPR', 'quLATi')) fid.write('{:<20}{:<20.6f}{:<20.6f}{:<20.6f}\n'.format(
# get vertex coordinates TrCoord = [vertices[i] for i in TrIdx] TstCoord = [vertices[i] for i in TstIdx] # get mapLAT signal values TrVal = [mapLAT[i] for i in TrIdx] TstVal = [mapLAT[i] for i in TstIdx] """ MAGIC-LAT estimate """ latEst = magicLAT(vertices, faces, TrIdx, TrCoord, TrVal, EDGE_THRESHOLD) """ GPR estimate """ gpr.fit(TrCoord, TrVal) latEstGPR = gpr.predict(vertices, return_std=False) """ quLATi estimate """ latEstquLATi = quLATiHelper.quLATi(TrIdx, TrVal, vertices, model) magicDE[test] = metrics.deltaE(TstVal, latEst[TstIdx], MINLAT, MAXLAT) gprDE[test] = metrics.deltaE(TstVal, latEstGPR[TstIdx], MINLAT, MAXLAT) quLATiDE[test] = metrics.deltaE(TstVal, latEstquLATi[TstIdx], MINLAT, MAXLAT) with open(meanFile, 'a') as fid: fid.write('\n') fid.write('{:<20}{:<20.6f}{:<20.6f}{:<20.6f}'.format( numSamps, np.average(magicDE), np.average(gprDE), np.average(quLATiDE))) with open(stdFile, 'a') as fid: fid.write('\n') fid.write('{:<20}{:<20.6f}{:<20.6f}{:<20.6f}'.format( numSamps, np.std(magicDE), np.std(gprDE), np.std(quLATiDE)))