orbit.diagnostics package

Submodules

orbit.diagnostics.plot module

orbit.diagnostics.plot.metric_horizon_barplot(df, model_col='model', pred_horizon_col='pred_horizon', metric_col='smape', bar_width=0.1, path=None, figsize=None, fontsize=None, is_visible=False)
orbit.diagnostics.plot.plot_bt_predictions(bt_pred_df, metrics=<function smape>, split_key_list=None, ncol=2, figsize=None, include_vline=True, title='', fontsize=20, path=None, is_visible=True)

function to plot and visualize the prediction results from back testing.

bt_pred_dfdata frame

the output of orbit.diagnostics.backtest.BackTester.fit_predict(), which includes the actuals/predictions for all the splits

metricscallable

the metric function

split_key_list: list; default None

with given model, which split keys to plot. If None, all the splits will be plotted

ncolint

number of columns of the panel; number of rows will be decided accordingly

figsizetuple

figure size

include_vlinebool

if plotting the vertical line to cut the in-sample and out-of-sample predictions for each split

titlestr

title of the plot

fontsize: int; optional

fontsize of the title

pathstring

path to save the figure

is_visiblebool

if displaying the figure

orbit.diagnostics.plot.plot_bt_predictions2(bt_pred_df, metrics=<function smape>, split_key_list=None, figsize=None, include_vline=True, title='', fontsize=20, markersize=50, lw=2, fig_dir=None, is_visible=True, fix_xylim=True, export_gif=False, imageio_args=None)

a different style backtest plot compare to plot_bt_prediction where it writes separate plot for each split; this is also used to produce an animation to summarize every split

orbit.diagnostics.plot.plot_predicted_components(predicted_df, date_col, prediction_percentiles=None, plot_components=None, title='', figsize=None, path=None, fontsize=None, is_visible=True)
Plot predicted components with the data frame of decomposed prediction where components

has been pre-defined as trend, seasonality and regression.

predicted_dfpd.DataFrame

predicted data response data frame. two columns required: actual_col and pred_col. If user provide pred_percentiles_col, it needs to include them as well.

date_colstr

the date column name

prediction_percentileslist

a list should consist exact two elements which will be used to plot as lower and upper bound of confidence interval

plot_componentslist

a list of strings to show the label of components to be plotted; by default, it uses values in orbit.constants.constants.PredictedComponents.

titlestr; optional

title of the plot

figsizetuple; optional

figsize pass through to matplotlib.pyplot.figure()

pathstr; optional

path to save the figure

fontsizeint; optional

fontsize of the title

is_visibleboolean

whether we want to show the plot. If called from unittest, is_visible might = False.

Returns

Return type

matplotlib axes object

orbit.diagnostics.plot.plot_predicted_data(training_actual_df, predicted_df, date_col, actual_col, pred_col='prediction', prediction_percentiles=None, title='', test_actual_df=None, is_visible=True, figsize=None, path=None, fontsize=None, line_plot=False, markersize=50, lw=2, linestyle='-')

plot training actual response together with predicted data; if actual response of predicted data is there, plot it too.

Parameters
  • training_actual_df (pd.DataFrame) – training actual response data frame. two columns required: actual_col and date_col

  • predicted_df (pd.DataFrame) – predicted data response data frame. two columns required: actual_col and pred_col. If user provide prediction_percentiles, it needs to include them as well in such prediction_{x} where x is the correspondent percentiles

  • prediction_percentiles (list) – list of two elements indicates the lower and upper percentiles

  • date_col (str) – the date column name

  • actual_col (str) –

  • pred_col (str) –

  • title (str) – title of the plot

  • test_actual_df (pd.DataFrame) – test actual response dataframe. two columns required: actual_col and date_col

  • is_visible (boolean) – whether we want to show the plot. If called from unittest, is_visible might = False.

  • figsize (tuple) – figsize pass through to matplotlib.pyplot.figure()

  • path (str) – path to save the figure

  • fontsize (int; optional) – fontsize of the title

  • line_plot (bool; default False) – if True, make line plot for observations; otherwise, make scatter plot for observations

  • markersize (int; optional) – point marker size

  • lw (int; optional) – out-of-sample prediction line width

  • linestyle (str) – linestyle of prediction plot

Returns

Return type

matplotlib axes object

Module contents