diff --git a/src/visuals/results.py b/src/visuals/results.py index 5f5adc6..a584c2a 100644 --- a/src/visuals/results.py +++ b/src/visuals/results.py @@ -26,19 +26,6 @@ def print_results(dic_stats, show=False, save=False): yy_gender = target_error(xx, mm_gender) yy_gps = np.linspace(5., 5., xx.shape[0]) - # # Recall results - # plt.figure(1) - # plt.xlabel("Distance [meters]") - # plt.ylabel("Detected instances") - # plt.xlim(x_min, x_max) - # for method in ['our', 'm3d', '3dop']: - # xxs = get_distances(clusters) - # dic_cnt = dic_stats[phase][method]['cnt'] - # cnts = get_values(dic_cnt, clusters) - # plt.plot(xxs, cnts, marker='s', label=method + '_method') - # plt.legend() - # plt.show() - # # Precision on same instances fig_name = 'results.png' plt.xlabel("Distance [meters]") @@ -158,103 +145,4 @@ def get_confidence_points(confidences, distances, errors): distance_points.append(dd) distance_points.append(dd) - return distance_points, confidence_points - - - -# def histogram(self): -# """ -# Visualize histograms to compare error performances of net and baseline -# """ -# # for mode in ['mean', 'std']: -# for mode in ['mean']: -# -# # for phase in ['train', 'val', 'test']: -# for phase in ['test']: -# -# err_geom = [] -# err_net = [] -# counts = [] -# clusters = ('10', '20', '30', '40', '50', '>50', 'all') -# for clst in clusters: -# -# err_geom.append(dic_geom[phase]['error'][clst][mode]) -# counts.append(dic_geom[phase]['error'][clst]['count']) -# err_net.append(dic_net[phase][clst][mode]) -# -# nn = len(clusters) -# -# # TODO Shortcut to print 2 models in a single histogram -# err_net_l1 = [1.1, 1.32, 2.19, 3.29, 4.38, 6.58, 2.21] -# -# ind = np.arange(nn) # the x locations for the groups -# width = 0.30 # the width of the bars -# -# fig, ax = plt.subplots() -# rects1 = ax.bar(ind, err_geom, width, color='b') -# rects2 = ax.bar(ind + width, err_net_l1, width, color='r') -# rects3 = ax.bar(ind + 2 * width, err_net, width, color='g') -# -# # add some text for labels, title and axes ticks -# ax.set_ylabel('Distance error [m]') -# ax.set_title(mode + ' of errors in ' + phase) -# ax.set_xticks(ind + width / 2) -# ax.set_xticklabels(clusters) -# -# ax.legend((rects1[0], rects2[0], rects3[0]), ('Geometrical', 'L1 Loss', 'Laplacian Loss')) -# -# # Attach a text label above each bar displaying number of annotations -# for idx, rect in enumerate(rects1): -# height = rect.get_height() -# count = counts[idx] -# ax.text(rect.get_x() + rect.get_width() / 2., 1.05 * height, -# '%d' % int(count), ha='center', va='bottom') -# -# plt.show() - - # def error(self): -# """ -# Visualize error as function of the distance on the test set and compare it with target errors based on human -# height analyses. We consider: -# Position error in meters due to a height variation of 7 cm (Standard deviation already knowing the sex) -# Position error not knowing the gender (13cm as average difference --> 7.5cm of error to add) -# """ -# phase = 'test' -# xx = np.linspace(0, 60, 100) -# mm_std = 0.04 -# mm_gender = 0.0556 -# clusters = tuple([clst for clst in dic_net[phase] if clst not in ['all', '>50']]) -# # errors_geom = [dic_geom[phase]['error'][clst][mode] for clst in clusters] -# errors_net = [dic_net[phase][clst]['mean'] for clst in clusters] -# confidences = [dic_net[phase][clst]['std'][0] for clst in clusters] -# distances = get_distances(clusters) -# dds, zzs = get_confidence_points(confidences, distances, errors_net) -# -# # Set the plot -# fig = plt.figure() -# ax = plt.subplot(111) -# plt.xlim(0, 50) -# plt.xlabel("Distance [meters]") -# plt.ylabel("Error [meters]") -# plt.title("Error on Z Position Estimate due to height variation") -# -# # Plot the target errors -# yy_std = target_error(xx, mm_std) -# yy_gender = target_error(xx, mm_gender) -# # yy_child = target_error(xx, mm_child) -# # yy_test = target_error(xx, mm_test) -# yy_gps = np.linspace(5., 5., xx.shape[0]) -# plt.plot(xx, yy_std, '--', label="Knowing the gender", color='g') -# plt.plot(xx, yy_gender, '--', label="NOT knowing the gender", color='b') -# plt.plot(xx, yy_gps, '-', label="GPS Error", color='y') -# -# for idx in range(0, len(dds), 2): -# -# plt.plot(dds[idx: idx+2], zzs[idx: idx+2], color='k') -# -# # Plot the geometric and net errors as dots -# _ = ax.plot(distances, errors_net, 'ro', marker='s', label="Network Error (test)", markersize='8') -# # _ = ax.plot(distances, errors_geom, 'ko', marker='o', label="Baseline Error", markersize='5') -# -# ax.legend(loc='upper left') -# plt.show() \ No newline at end of file + return distance_points, confidence_points \ No newline at end of file