Visualization of Forecasts
Modules
- prosper_nn.utils.visualize_forecasts.heatmap_forecasts(forecasts: Tensor, sigma: float = 0.05, num_interp: int = 15, window_height: int = 100, batch_first: bool = False, save_at: str | None = None, xlabel: str = 'Forecast Horizon', ylabel: str = 'Values', title: str = 'Heatmap Ensemble Forecast') None [source]
The function first interpolates values between the timesteps of the forecasts. Then for each pixel a heat is calculated with a gauss function and the result is plotted as a heatmap figure. The heat represents how many and how close the time series in forecasts are to the entry. At the end the heatmap is plotted.
- Parameters:
forecasts (torch.tensor) – A multidimensional torch tensor. Each row of the tensor contains a forecast.
sigma (float) – When the heat of a pixel is computed, a gaussian function is applied. The variable sigma is a value for the width of the gauss curve.
num_interp (int) – The amount of points, which get interpolated between two timesteps in a forecast.
window_height (int) – The amount of pixels in the height of the heatmap.
batch_first – This is only necessary for recurrent neural networks when in the networks batch_first=True.
save_at (str) – If defined the plot is saved as a png in the given file name.
xlabel (str) – The label of the x axis in the plot.
ylabel (str) – The label of the y axis in the plot.
title (str) – The title that is shown in the plot.
- Return type:
None
- prosper_nn.utils.visualize_forecasts.plot_time_series(expected_time_series: tensor, target: Tensor | None = None, uncertainty: Tensor | None = None, save_at: str | None = None, xlabel: str = 'Time steps', ylabel: str = 'Output', title: str = 'Expected time series/Target comparison', labels: List[str] | None = None) None [source]
Plot time series in line-style in a nice way. There are different possibilities what should be included in the plot. It is necessary to plot at least one time series (expected_time_series), but it is optional if a target time series and/or the uncertainty of the time series should be included in the plot.
- Parameters:
expected_time_series (torch.tensor) – A one dimensional torch tensor which represents a time series. For example this can be the result of a forecast.
target (torch.Tensor) – The variable is an one dimensional torch tensor that represents the target line of a forecast. The target is optional. If no target is given it is not included in the plot.
uncertainty (torch.Tensor) – The uncertainty variable is a multidimensional torch tensor. Each column should represent one time series. If an ensemble model is calculated, the single forecasts from the models included in the ensemble can be seen as uncertainty of the mean output. Therefore, all the forecasts of the single models are plotted to the figure if a variable is given.
save_at (str) – If defined the plot is saved as a png in the given file name.
xlabel (str) – The label of the x axis in the plot.
ylabel (str) – The label of the y axis in the plot.
title (str) – The title that is shown in the plot.
labels (List[str]) – If labels are given they are used for describing the plotted curves. Define one or two labels depending if target is defined or not. For uncertainty no label can be given.
- Return type:
None
Example
X = torch.arange(10)
plot_time_series(X)