plot_anomalies_interactive(ts: TSDataset, segment: str, method: Callable[[...], Dict[str, List[pandas._libs.tslibs.timestamps.Timestamp]]], params_bounds: Dict[str, Tuple[Union[int, float], Union[int, float], Union[int, float]]], in_column: str = 'target', figsize: Tuple[int, int] = (20, 10), start: Optional[str] = None, end: Optional[str] = None)[source]

Plot a time series with indicated anomalies.

Anomalies are obtained using the specified method. The method parameters values can be changed using the corresponding sliders.

  • ts (TSDataset) – TSDataset with timeseries data

  • segment (str) – Segment to plot

  • method (Callable[[...], Dict[str, List[pandas._libs.tslibs.timestamps.Timestamp]]]) – Method for outliers detection, e.g. get_anomalies_density()

  • params_bounds (Dict[str, Tuple[Union[int, float], Union[int, float], Union[int, float]]]) – Parameters ranges of the outliers detection method. Bounds for the parameter are (min,max,step)

  • in_column (str) – column to plot

  • figsize (Tuple[int, int]) – size of the figure in inches

  • start (Optional[str]) – start timestamp for plot

  • end (Optional[str]) – end timestamp for plot


Jupyter notebook might display the results incorrectly, in this case try to use !jupyter nbextension enable --py widgetsnbextension.


>>> from etna.datasets import TSDataset
>>> from etna.datasets import generate_ar_df
>>> from etna.analysis import plot_anomalies_interactive, get_anomalies_density
>>> classic_df = generate_ar_df(periods=1000, start_time="2021-08-01", n_segments=2)
>>> df = TSDataset.to_dataset(classic_df)
>>> ts = TSDataset(df, "D")
>>> params_bounds = {"window_size": (5, 20, 1), "distance_coef": (0.1, 3, 0.25)}
>>> method = get_anomalies_density
>>> plot_anomalies_interactive(ts=ts, segment="segment_1", method=method, params_bounds=params_bounds, figsize=(20, 10))