MCPcopy Create free account
hub / github.com/HazyResearch/spacetime / plot_forecasts

Function plot_forecasts

train/evaluate.py:29–52  ·  view source on GitHub ↗
(y_by_splits, splits, feature_dim=0, axes=None)

Source from the content-addressed store, hash-verified

27
28
29def 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
55def get_plotting_samples(y):

Callers 1

mainFunction · 0.90

Calls 1

get_plotting_samplesFunction · 0.85

Tested by

no test coverage detected