merlion.plot package
Module for visualizing model predictions.
- merlion.plot.plot_anoms(ax, anomaly_labels)
Plots anomalies as pink windows on the matplotlib
Axes
objectax
.
- merlion.plot.plot_anoms_plotly(fig, anomaly_labels)
Plots anomalies as pink windows on the plotly
Figure
objectfig
.
- class merlion.plot.Figure(y=None, anom=None, yhat=None, yhat_lb=None, yhat_ub=None, y_prev=None, yhat_prev=None, yhat_prev_lb=None, yhat_prev_ub=None, yhat_color=None)
Bases:
object
Class for visualizing predictions of univariate anomaly detection & forecasting models.
- Parameters
y (
Optional
[UnivariateTimeSeries
]) – the true value of the time seriesanom (
Optional
[UnivariateTimeSeries
]) – anomaly scores returned by a modelyhat (
Optional
[UnivariateTimeSeries
]) – forecast returned by a modelyhat_lb (
Optional
[UnivariateTimeSeries
]) – lower bound onyhat
(if model supports uncertainty estimation)yhat_ub (
Optional
[UnivariateTimeSeries
]) – upper bound onyhat
(if model supports uncertainty estimation)y_prev (
Optional
[UnivariateTimeSeries
]) – portion of time series precedingy
yhat_prev (
Optional
[UnivariateTimeSeries
]) – model’s forecast ofy_prev
yhat_prev_lb (
Optional
[UnivariateTimeSeries
]) – lower bound onyhat_prev
(if model supports uncertainty estimation)yhat_prev_ub (
Optional
[UnivariateTimeSeries
]) – upper bound onyhat_prev
(if model supports uncertainty estimation)yhat_color (
Optional
[str
]) – the color in which to plot the forecast
- property t0
- Returns
First time being plotted.
- property tf
- Returns
Final time being plotted.
- property t_split
- Returns
Time splitting train from test.
- get_y()
Get all y’s (actual values)
- get_yhat()
Get all yhat’s (predicted values).
- get_yhat_iqr()
Get IQR of predicted values.
- plot(title=None, metric_name=None, figsize=(1000, 600), ax=None, label_alias=None)
Plots the figure in matplotlib.
- Parameters
title – title of the plot.
metric_name – name of the metric (y axis)
figsize – figure size in pixels
ax – matplotlib axes to add the figure to.
label_alias (
Optional
[Dict
[str
,str
]]) – dict which maps entities in the figure, specificallyy_hat
andanom
to their label names.
- Returns
(fig, ax): matplotlib figure & matplotlib axes
- plot_plotly(title=None, metric_name=None, figsize=(1000, 600), label_alias=None)
Plots the figure in plotly.
- Parameters
title – title of the plot.
metric_name – name of the metric (y axis)
figsize – figure size in pixels
label_alias (
Optional
[Dict
[str
,str
]]) – dict which maps entities in the figure, specificallyy_hat
andanom
to their label names.
- Returns
plotly figure.
- class merlion.plot.MTSFigure(y=None, anom=None, yhat=None, yhat_lb=None, yhat_ub=None, y_prev=None, yhat_prev=None, yhat_prev_lb=None, yhat_prev_ub=None, yhat_color=None)
Bases:
object
- property t0
- property tf
- property t_split
- get_y()
Get all y’s (actual values)
- get_yhat()
Get all yhat’s (predicted values).
- get_yhat_iqr()
Get IQR of predicted values.
- plot_plotly(title=None, figsize=None)
Plots the figure in plotly. :type title: :param title: title of the plot. :type figsize: :param figsize: figure size in pixels :return: plotly figure.