class_docstr: STRAY: robust anomaly detection in data streams with concept drift.
  
  This is based on STRAY (Search TRace AnomalY) _[1], which is a modification
  of HDoutliers _[2]. HDoutliers is a powerful algorithm for the detection of
  anomalous observations in a dataset, which has (among other advantages) the
  ability to detect clusters of outliers in multi-dimensional data without
  requiring a model of the typical behavior of the system. However, it suffers
  from some limitations that affect its accuracy. STRAY is an extension of
  HDoutliers that uses extreme value theory for the anomalous threshold
  calculation, to deal with data streams that exhibit non-stationary behavior.
  
  Parameters
  ----------
  alpha : float, optional (default=0.01)
      Threshold for determining the cutoff for outliers. Observations are
      considered outliers if they fall in the (1 - alpha) tail of
      the distribution of the nearest-neighbor distances between exemplars.
  k : int, optional (default=10)
      Number of neighbours considered.
  knn_algorithm : str {"auto", "ball_tree", "kd_tree", "brute"}, optional
      (default="brute")
      Algorithm used to compute the nearest neighbors, from
      sklearn.neighbors.NearestNeighbors
  p : float, optional (default=0.5)
      Proportion of possible candidates for outliers. This defines the starting point
      for the bottom up searching algorithm.
  size_threshold : int, optional (default=50)
      Sample size to calculate an empirical threshold.
  outlier_tail : str {"min", "max"}, optional (default="max")
      Direction of the outlier tail.
  
  Attributes
  ----------
  score_ : pd.Series
      Outlier score of each data point in X.
  y_ : pd.Series
      Outlier boolean flag for each data point in X.
  
  References
  ----------
  .. [1] Talagala, Priyanga Dilini, Rob J. Hyndman, and Kate Smith-Miles.
  "Anomaly detection in high-dimensional data." Journal of Computational
  and Graphical Statistics 30.2 (2021): 360-374.
  .. [2] Wilkinson, Leland. "Visualizing big data outliers through
  distributed aggregation." IEEE transactions on visualization and
  computer graphics 24.1 (2017): 256-266.
  
  Examples
  --------
  >>> from sktime.annotation.stray import STRAY
  >>> from sktime.datasets import load_airline
  >>> from sklearn.preprocessing import MinMaxScaler
  >>> import numpy as np
  >>> X = load_airline().to_frame().to_numpy()
  >>> scaler = MinMaxScaler()
  >>> X = scaler.fit_transform(X)
  >>> model = STRAY(k=3)
  >>> y = model.fit_transform(X)
  >>> y[:5]
  array([False, False, False, False, False])
class_docstr_tok: ["STRAY",":","robust","anomaly","detection","in","data","streams","with","concept","drift",".","This","is","based","on","STRAY","(","Search","TRace","AnomalY",")","_","[","1","]",",","which","is","a","modification","of","HDoutliers","_","[","2","]",".","HDoutliers","is","a","powerful","algorithm","for","the","detection","of","anomalous","observations","in","a","dataset",",","which","has","(","among","other","advantages",")","the","ability","to","detect","clusters","of","outliers","in","multi-dimensional","data","without","requiring","a","model","of","the","typical","behavior","of","the","system",".","However",",","it","suffers","from","some","limitations","that","affect","its","accuracy",".","STRAY","is","an","extension","of","HDoutliers","that","uses","extreme","value","theory","for","the","anomalous","threshold","calculation",",","to","deal","with","data","streams","that","exhibit","non-stationary","behavior",".","Parameters","--","--","--","--","--","alpha",":","float",",","optional","(","default=0.01",")","Threshold","for","determining","the","cutoff","for","outliers",".","Observations","are","considered","outliers","if","they","fall","in","the","(","1","-","alpha",")","tail","of","the","distribution","of","the","nearest-neighbor","distances","between","exemplars",".","k",":","int",",","optional","(","default=10",")","Number","of","neighbours","considered",".","knn_algorithm",":","str","{","``","auto","''",",","``","ball_tree","''",",","``","kd_tree","''",",","``","brute","''","}",",","optional","(","default=","''","brute","''",")","Algorithm","used","to","compute","the","nearest","neighbors",",","from","sklearn.neighbors.NearestNeighbors","p",":","float",",","optional","(","default=0.5",")","Proportion","of","possible","candidates","for","outliers",".","This","defines","the","starting","point","for","the","bottom","up","searching","algorithm",".","size_threshold",":","int",",","optional","(","default=50",")","Sample","size","to","calculate","an","empirical","threshold",".","outlier_tail",":","str","{","``","min","''",",","``","max","''","}",",","optional","(","default=","''","max","''",")","Direction","of","the","outlier","tail",".","Attributes","--","--","--","--","--","score_",":","pd.Series","Outlier","score","of","each","data","point","in","X.","y_",":","pd.Series","Outlier","boolean","flag","for","each","data","point","in","X.","References","--","--","--","--","--","..","[","1","]","Talagala",",","Priyanga","Dilini",",","Rob","J.","Hyndman",",","and","Kate","Smith-Miles",".","``","Anomaly","detection","in","high-dimensional","data",".","''","Journal","of","Computational","and","Graphical","Statistics","30.2","(","2021",")",":","360-374",".","..","[","2","]","Wilkinson",",","Leland",".","``","Visualizing","big","data","outliers","through","distributed","aggregation",".","''","IEEE","transactions","on","visualization","and","computer","graphics","24.1","(","2017",")",":","256-266",".","Examples","--","--","--","--",">",">",">","from","sktime.annotation.stray","import","STRAY",">",">",">","from","sktime.datasets","import","load_airline",">",">",">","from","sklearn.preprocessing","import","MinMaxScaler",">",">",">","import","numpy","as","np",">",">",">","X","=","load_airline","(",")",".to_frame","(",")",".to_numpy","(",")",">",">",">","scaler","=","MinMaxScaler","(",")",">",">",">","X","=","scaler.fit_transform","(","X",")",">",">",">","model","=","STRAY","(","k=3",")",">",">",">","y","=","model.fit_transform","(","X",")",">",">",">","y","[",":5","]","array","(","[","False",",","False",",","False",",","False",",","False","]",")"]
docstr: Return anomaly detection.
  
  Parameters
  ----------
  X : np.ArrayLike
      Data for anomaly detection (time series).
  
  Returns
  -------
  y_ : np.ArrayLike
      Anomaly detection, boolean.
docstr_tok: ["Return","anomaly","detection",".","Parameters","--","--","--","--","--","X",":","np.ArrayLike","Data","for","anomaly","detection","(","time","series",")",".","Returns","--","--","--","-","y_",":","np.ArrayLike","Anomaly","detection",",","boolean","."]
code: def _transform(
      self, X: npt.ArrayLike, y: npt.ArrayLike = None
  ) -> npt.ArrayLike:
      """Return anomaly detection.
  
      Parameters
      ----------
      X : np.ArrayLike
          Data for anomaly detection (time series).
  
      Returns
      -------
      y_ : np.ArrayLike
          Anomaly detection, boolean.
      """
      # fit again if data is different to fit, but don't store anything
      if not np.allclose(X, self._X, equal_nan=True):
          new_obj = STRAY(
              alpha=self.alpha,
              k=self.k,
              knn_algorithm=self.knn_algorithm,
              p=self.p,
              size_threshold=self.size_threshold,
              outlier_tail=self.outlier_tail,
          ).fit(X)
          warnings.warn(
              "Warning: Input data X differs from that given to fit(). "
              "Refitting with new input data, not storing updated public class "
              "attributes. For this, explicitly use fit(X) or fit_transform(X).",
              stacklevel=2,
          )
          return new_obj.y_.astype(bool)
  
      return self.y_.astype(bool)
  
file_path: sktime/sktime/annotation/stray.py
imports: import warnings
  from typing import Dict
  import numpy
  import numpy.typing
  from sklearn.neighbors import NearestNeighbors
  from sktime.transformations.base import BaseTransformer
label_desc: Use image node_id 6 for calling the STRAY obj's underlying member method code with example usage: obj._transform(X, y) and returns: self, new_obj