MCPcopy Create free account
hub / github.com/RolnickLab/climart / level_errors

Function level_errors

climart/utils/plotting.py:185–203  ·  view source on GitHub ↗
(Y_true, Y_preds, epoch)

Source from the content-addressed store, hash-verified

183
184
185def level_errors(Y_true, Y_preds, epoch):
186 errors = np.mean((Y_true - Y_preds), axis=0)
187 colours = ['red' if x < 0 else 'green' for x in errors]
188 index = np.arange(0, len(colours), 1)
189
190 # Draw plot
191 lev_fig = plt.figure(figsize=(14, 14), dpi=80)
192 plt.hlines(y=index, xmin=0, xmax=errors)
193 for x, y, tex in zip(errors, index, errors):
194 t = plt.text(x, y, round(tex, 2), horizontalalignment='right' if x < 0 else 'left',
195 verticalalignment='center', fontdict={'color': 'red' if x < 0 else 'green', 'size': 10})
196
197 # Styling
198 plt.yticks(index, ['Level: ' + str(z) for z in index], fontsize=12)
199 plt.title(f'Average Level-wise error for epoch: {epoch}', fontdict={'size': 20})
200 plt.grid(linestyle='--', alpha=0.5)
201 plt.xlim(-5, 5)
202
203 return lev_fig
204
205
206def profile_errors(Y_true, Y_preds, plot_profiles=200, var_name=None, data_dir: str = None,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected