class_docstr: Page-Hinkley method for concept drift detection.
  
  This change detection method works by computing the observed values and their mean
  up to the current moment. Page-Hinkley does not signal warning zones, only change detections.
  
  This detector implements the CUSUM control chart for detecting changes. This implementation also supports
  the two-sided Page-Hinkley test to detect increasing and decreasing changes in the mean of the input
  values.
  
  Parameters
  ----------
  min_instances
      The minimum number of instances before detecting change.
  delta
      The delta factor for the Page-Hinkley test.
  threshold
      The change detection threshold (lambda).
  alpha
      The forgetting factor, used to weight the observed value and the mean.
  mode
      Whether to consider increases ("up"), decreases ("down") or both ("both") when monitoring the fading mean.
  
  Examples
  --------
  >>> import random
  >>> from river import drift
  
  >>> rng = random.Random(12345)
  >>> ph = drift.PageHinkley()
  
  >>> # Simulate a data stream composed by two data distributions
  >>> data_stream = rng.choices([0, 1], k=1000) + rng.choices(range(4, 8), k=1000)
  
  >>> # Update drift detector and verify if change is detected
  >>> for i, val in enumerate(data_stream):
  ...     ph.update(val)
  ...     if ph.drift_detected:
  ...         print(f"Change detected at index {i}, input value: {val}")
  Change detected at index 1006, input value: 5
  
  References
  ----------
  [^1]: E. S. Page. 1954. Continuous Inspection Schemes. Biometrika 41, 1/2 (1954), 100-115.
  [^2]: Sebastião, R., & Fernandes, J. M. (2017, June). Supporting the Page-Hinkley test with
  empirical mode decomposition for change detection. In International Symposium on Methodologies
  for Intelligent Systems (pp. 492-498). Springer, Cham.
class_docstr_tok: ["Page-Hinkley","method","for","concept","drift","detection",".","This","change","detection","method","works","by","computing","the","observed","values","and","their","mean","up","to","the","current","moment",".","Page-Hinkley","does","not","signal","warning","zones",",","only","change","detections",".","This","detector","implements","the","CUSUM","control","chart","for","detecting","changes",".","This","implementation","also","supports","the","two-sided","Page-Hinkley","test","to","detect","increasing","and","decreasing","changes","in","the","mean","of","the","input","values",".","Parameters","--","--","--","--","--","min_instances","The","minimum","number","of","instances","before","detecting","change",".","delta","The","delta","factor","for","the","Page-Hinkley","test",".","threshold","The","change","detection","threshold","(","lambda",")",".","alpha","The","forgetting","factor",",","used","to","weight","the","observed","value","and","the","mean",".","mode","Whether","to","consider","increases","(","``","up","''",")",",","decreases","(","``","down","''",")","or","both","(","``","both","''",")","when","monitoring","the","fading","mean",".","Examples","--","--","--","--",">",">",">","import","random",">",">",">","from","river","import","drift",">",">",">","rng","=","random.Random","(","12345",")",">",">",">","ph","=","drift.PageHinkley","(",")",">",">",">","#","Simulate","a","data","stream","composed","by","two","data","distributions",">",">",">","data_stream","=","rng.choices","(","[","0",",","1","]",",","k=1000",")","+","rng.choices","(","range","(","4",",","8",")",",","k=1000",")",">",">",">","#","Update","drift","detector","and","verify","if","change","is","detected",">",">",">","for","i",",","val","in","enumerate","(","data_stream",")",":","...","ph.update","(","val",")","...","if","ph.drift_detected",":","...","print","(","f","''","Change","detected","at","index","{","i","}",",","input","value",":","{","val","}","''",")","Change","detected","at","index","1006",",","input","value",":","5","References","--","--","--","--","--","[","^1","]",":","E.","S.","Page",".","1954",".","Continuous","Inspection","Schemes",".","Biometrika","41",",","1\/2","(","1954",")",",","100-115",".","[","^2","]",":","Sebasti\u00e3o",",","R.",",","&","Fernandes",",","J.","M.","(","2017",",","June",")",".","Supporting","the","Page-Hinkley","test","with","empirical","mode","decomposition","for","change","detection",".","In","International","Symposium","on","Methodologies","for","Intelligent","Systems","(","pp",".","492-498",")",".","Springer",",","Cham","."]
code: def _reset(self):
      super()._reset()
      self._x_mean = stats.Mean()
      self._sum_increase = 0.0
      self._sum_decrease = 0.0
  
      self._min_increase = float("inf")
      self._max_decrease = -1
  
      if self.mode == self._MODE_UP:
          self._test_drift = self._test_increase
      elif self.mode == self._MODE_DOWN:
          self._test_drift = self._test_decrease
      else:
          self._test_drift = self._test_both
  
file_path: river/river/drift/page_hinkley.py
imports: from __future__ import annotations
  from river import stats
  from river.base import DriftDetector
label_desc: Use image node_id 2 for calling the PageHinkley obj's underlying member method code with example usage: obj._reset() without return types