DensityOutliersTransform¶
- class DensityOutliersTransform(in_column: str, window_size: int = 15, distance_coef: float = 3, n_neighbors: int = 3, distance_func: typing.Callable[[float, float], float] = <function absolute_difference_distance>)[source]¶
Bases:
etna.transforms.outliers.base.OutliersTransform
Transform that uses
get_anomalies_density()
to find anomalies in data.Warning
This transform can suffer from look-ahead bias. For transforming data at some timestamp it uses information from the whole train part.
Create instance of DensityOutliersTransform.
- Parameters
in_column (str) – name of processed column
window_size (int) – size of windows to build
distance_coef (float) – factor for standard deviation that forms distance threshold to determine points are close to each other
n_neighbors (int) – min number of close neighbors of point not to be outlier
distance_func (Callable[[float, float], float]) – distance function
- Inherited-members
Methods
detect_outliers
(ts)Call
get_anomalies_density()
function with self parameters.fit
(ts)Fit the transform.
fit_transform
(ts)Fit and transform TSDataset.
get_regressors_info
()Return the list with regressors created by the transform.
inverse_transform
(ts)Inverse transform TSDataset.
load
(path)Load an object.
Get default grid for tuning hyperparameters.
save
(path)Save the object.
set_params
(**params)Return new object instance with modified parameters.
to_dict
()Collect all information about etna object in dict.
transform
(ts)Transform TSDataset inplace.
- detect_outliers(ts: etna.datasets.tsdataset.TSDataset) Dict[str, List[pandas._libs.tslibs.timestamps.Timestamp]] [source]¶
Call
get_anomalies_density()
function with self parameters.- Parameters
ts (etna.datasets.tsdataset.TSDataset) – dataset to process
- Returns
dict of outliers in format {segment: [outliers_timestamps]}
- Return type
Dict[str, List[pandas._libs.tslibs.timestamps.Timestamp]]
- params_to_tune() Dict[str, etna.distributions.distributions.BaseDistribution] [source]¶
Get default grid for tuning hyperparameters.
This grid tunes parameters:
window_size
,distance_coef
,n_neighbors
. Other parameters are expected to be set by the user.- Returns
Grid to tune.
- Return type
Dict[str, etna.distributions.distributions.BaseDistribution]