MCPcopy Create free account
hub / github.com/MarcCoru/locationencoder / plot_summary

Function plot_summary

experiments/exp_longitudinal_accuracy.py:93–131  ·  view source on GitHub ↗
(resultsdir, neuralnet, savepath=None)

Source from the content-addressed store, hash-verified

91 print(f"writing {csvfile}")
92
93def plot_summary(resultsdir, neuralnet, savepath=None):
94
95 runs = os.listdir(resultsdir)
96 runs = [r for r in runs if os.path.isdir(os.path.join(resultsdir,r))]
97
98 colors = ['#e41a1c', # Red
99 '#377eb8', # Blue
100 '#4daf4a', # Green
101 '#984ea3'] # Purple
102
103 runs = [r for r in runs if neuralnet in r]
104 legend_names = [n.replace(f"-{neuralnet}", "") for n in runs]
105
106 N = len(runs)
107
108 fig, ax = plt.subplots()
109
110 for o, run, color in zip(np.linspace(-N/2, N/2,N), runs, colors):
111 file = np.load(os.path.join(resultsdir, run, "histogram.npz"))
112 hist_accuracy = file["hist_accuracy"]
113 bin_width = file["bin_width"]
114
115 bin_edges = file["bin_edges"] #np.linspace(-90,90, 10)
116 heights = np.diff(bin_edges) * 0.9 / N
117
118 offset = o * heights[0]/1.5
119
120 ax.barh(bin_edges[:-1] + bin_width / 2 + offset, hist_accuracy,
121 height=heights, align='center', color=color)
122
123 ax.legend(legend_names, ncols=1, loc="lower left")
124
125 ax.set_xlabel("accuracy")
126 ax.set_ylabel("latitude")
127 ax.set_yticks(bin_edges[:-1] + bin_width / 2)
128
129 if savepath is not None:
130 print(f"writing {savepath}")
131 fig.savefig(savepath, bbox_inches="tight", pad_inches=0, transparent=True)
132
133if __name__ == '__main__':
134 main()

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected