class_docstr: Threshold anomaly filter.
  
  Parameters
  ----------
  anomaly_detector
      An anomaly detector.
  q
      The quantile level above which to classify an anomaly score as anomalous.
  protect_anomaly_detector
      Indicates whether or not the anomaly detector should be updated when the anomaly score is
      anomalous. If the data contains sporadic anomalies, then the anomaly detector should likely
      not be updated. Indeed, if it learns the anomaly score, then it will slowly start to
      consider anomalous anomaly scores as normal. This might be desirable, for instance in the
      case of drift.
  
  Examples
  --------
  
  >>> from river import anomaly
  >>> from river import compose
  >>> from river import datasets
  >>> from river import metrics
  >>> from river import preprocessing
  
  >>> model = compose.Pipeline(
  ...     preprocessing.MinMaxScaler(),
  ...     anomaly.QuantileFilter(
  ...         anomaly.HalfSpaceTrees(seed=42),
  ...         q=0.95
  ...     )
  ... )
  
  >>> report = metrics.ClassificationReport()
  
  >>> for x, y in datasets.CreditCard().take(2000):
  ...     score = model.score_one(x)
  ...     is_anomaly = model['QuantileFilter'].classify(score)
  ...     model.learn_one(x)
  ...     report.update(y, is_anomaly)
  
  >>> report
                 Precision   Recall   F1       Support
  <BLANKLINE>
         0      99.95%   94.49%   97.14%      1998
         1       0.90%   50.00%    1.77%         2
  <BLANKLINE>
     Macro      50.42%   72.25%   49.46%
     Micro      94.45%   94.45%   94.45%
  Weighted      99.85%   94.45%   97.05%
  <BLANKLINE>
                   94.45% accuracy
class_docstr_tok: ["Threshold","anomaly","filter",".","Parameters","--","--","--","--","--","anomaly_detector","An","anomaly","detector",".","q","The","quantile","level","above","which","to","classify","an","anomaly","score","as","anomalous",".","protect_anomaly_detector","Indicates","whether","or","not","the","anomaly","detector","should","be","updated","when","the","anomaly","score","is","anomalous",".","If","the","data","contains","sporadic","anomalies",",","then","the","anomaly","detector","should","likely","not","be","updated",".","Indeed",",","if","it","learns","the","anomaly","score",",","then","it","will","slowly","start","to","consider","anomalous","anomaly","scores","as","normal",".","This","might","be","desirable",",","for","instance","in","the","case","of","drift",".","Examples","--","--","--","--",">",">",">","from","river","import","anomaly",">",">",">","from","river","import","compose",">",">",">","from","river","import","datasets",">",">",">","from","river","import","metrics",">",">",">","from","river","import","preprocessing",">",">",">","model","=","compose.Pipeline","(","...","preprocessing.MinMaxScaler","(",")",",","...","anomaly.QuantileFilter","(","...","anomaly.HalfSpaceTrees","(","seed=42",")",",","...","q=0.95","...",")","...",")",">",">",">","report","=","metrics.ClassificationReport","(",")",">",">",">","for","x",",","y","in","datasets.CreditCard","(",")",".take","(","2000",")",":","...","score","=","model.score_one","(","x",")","...","is_anomaly","=","model","[","'QuantileFilter","'","]",".classify","(","score",")","...","model.learn_one","(","x",")","...","report.update","(","y",",","is_anomaly",")",">",">",">","report","Precision","Recall","F1","Support","<","BLANKLINE",">","0","99.95","%","94.49","%","97.14","%","1998","1","0.90","%","50.00","%","1.77","%","2","<","BLANKLINE",">","Macro","50.42","%","72.25","%","49.46","%","Micro","94.45","%","94.45","%","94.45","%","Weighted","99.85","%","94.45","%","97.05","%","<","BLANKLINE",">","94.45","%","accuracy"]
code: def __init__(
      self, anomaly_detector, q: float, protect_anomaly_detector=True
  ):
      super().__init__(
          anomaly_detector=anomaly_detector,
          protect_anomaly_detector=protect_anomaly_detector,
      )
      self.quantile = stats.Quantile(q=q)
  
file_path: river/river/anomaly/filter.py
imports: from __future__ import annotations
  import math
  from river import anomaly, stats
label_desc: Use image node_id 1 to create a new QuantileFilter object from inherited base classes: anomaly.base with example: obj = QuantileFilter(anomaly_detector, q, protect_anomaly_detector)