(y_by_splits, splits, feature_dim=0, axes=None)
| 27 | |
| 28 | |
| 29 | def plot_forecasts(y_by_splits, splits, feature_dim=0, axes=None): |
| 30 | # Save / plot predictions |
| 31 | |
| 32 | n_plots = len(splits) # hard-coded for now |
| 33 | if axes is None: |
| 34 | fig, axes = plt.subplots(1, n_plots, |
| 35 | figsize=(6.4 * n_plots, 4.8 * n_plots)) |
| 36 | |
| 37 | for split_ix, split in enumerate(splits): |
| 38 | y = y_by_splits[split] |
| 39 | |
| 40 | # Visualization |
| 41 | samples_to_plot = get_plotting_samples(y) |
| 42 | pred_ix = 0 |
| 43 | for pred_type, pred_samples in samples_to_plot.items(): |
| 44 | if pred_type != 'true': |
| 45 | axis = axes[split_ix] |
| 46 | axis.plot(samples_to_plot['true'][..., feature_dim], |
| 47 | label='true', color='tab:orange') |
| 48 | axis.plot(pred_samples[..., feature_dim], |
| 49 | label=pred_type, color='tab:blue', linestyle='--') |
| 50 | pred_ix += 1 |
| 51 | axis.legend() |
| 52 | axis.set_title(f'{split} forecasts', size=15) |
| 53 | |
| 54 | |
| 55 | def get_plotting_samples(y): |
no test coverage detected