class_docstr: Use HampelFilter to detect outliers based on a sliding window.
  
  Correction of outliers is recommended by means of the sktime.Imputer,
  so both can be tuned separately.
  
  Parameters
  ----------
  window_length : int, optional (default=10)
      Length of the sliding window
  n_sigma : int, optional
      Defines how strong a point must outly to be an "outlier", by default 3
  k : float, optional
      A constant scale factor which is dependent on the distribution,
      for Gaussian it is approximately 1.4826, by default 1.4826
  return_bool : bool, optional
      If True, outliers are filled with True and non-outliers with False.
      Else, outliers are filled with np.nan.
  
  Notes
  -----
  Implementation is based on [1]_.
  
  References
  ----------
  .. [1] Hampel F. R., "The influence curve and its role in robust estimation",
     Journal of the American Statistical Association, 69, 382–393, 1974
  
  Examples
  --------
  >>> from sktime.transformations.series.outlier_detection import HampelFilter
  >>> from sktime.datasets import load_airline
  >>> y = load_airline()
  >>> transformer = HampelFilter(window_length=10)
  >>> y_hat = transformer.fit_transform(y)
class_docstr_tok: ["Use","HampelFilter","to","detect","outliers","based","on","a","sliding","window",".","Correction","of","outliers","is","recommended","by","means","of","the","sktime.Imputer",",","so","both","can","be","tuned","separately",".","Parameters","--","--","--","--","--","window_length",":","int",",","optional","(","default=10",")","Length","of","the","sliding","window","n_sigma",":","int",",","optional","Defines","how","strong","a","point","must","outly","to","be","an","``","outlier","''",",","by","default","3","k",":","float",",","optional","A","constant","scale","factor","which","is","dependent","on","the","distribution",",","for","Gaussian","it","is","approximately","1.4826",",","by","default","1.4826","return_bool",":","bool",",","optional","If","True",",","outliers","are","filled","with","True","and","non-outliers","with","False",".","Else",",","outliers","are","filled","with","np.nan",".","Notes","--","--","-","Implementation","is","based","on","[","1","]","_.","References","--","--","--","--","--","..","[","1","]","Hampel","F.","R.",",","``","The","influence","curve","and","its","role","in","robust","estimation","''",",","Journal","of","the","American","Statistical","Association",",","69",",","382\u2013393",",","1974","Examples","--","--","--","--",">",">",">","from","sktime.transformations.series.outlier_detection","import","HampelFilter",">",">",">","from","sktime.datasets","import","load_airline",">",">",">","y","=","load_airline","(",")",">",">",">","transformer","=","HampelFilter","(","window_length=10",")",">",">",">","y_hat","=","transformer.fit_transform","(","y",")"]
docstr: Logic internal to the algorithm for transforming the input series.
  
  Parameters
  ----------
  Z : pd.Series
  
  Returns
  -------
  pd.Series
docstr_tok: ["Logic","internal","to","the","algorithm","for","transforming","the","input","series",".","Parameters","--","--","--","--","--","Z",":","pd.Series","Returns","--","--","--","-","pd.Series"]
code: def _transform_series(self, Z):
      """Logic internal to the algorithm for transforming the input series.
  
      Parameters
      ----------
      Z : pd.Series
  
      Returns
      -------
      pd.Series
      """
      # warn if nan values in Series, as user might mix them
      # up with outliers otherwise
      if Z.isnull().values.any():
          warnings.warn(
              """Series contains nan values, more nan might be
                  added if there are outliers""",
              stacklevel=2,
          )
  
      cv = SlidingWindowSplitter(
          fh=0,
          window_length=self.window_length,
          step_length=1,
          start_with_window=True,
      )
      half_window_length = int(self.window_length / 2)
  
      Z = _hampel_filter(
          Z=Z,
          cv=cv,
          n_sigma=self.n_sigma,
          half_window_length=half_window_length,
          k=self.k,
      )
  
      # data post-processing
      if self.return_bool:
          Z = Z.apply(lambda x: bool(np.isnan(x)))
  
      return Z
  
file_path: sktime/sktime/transformations/series/outlier_detection.py
imports: import warnings
  from math import ceil
  import numpy
  import pandas
  from sktime.split import SlidingWindowSplitter
  from sktime.transformations.base import BaseTransformer
label_desc: Use image node_id 3 for calling the HampelFilter obj's underlying member method code with example usage: obj._transform_series(Z) and returns: Z