class_docstr: Streaming Random Patches ensemble regressor.
  
  The Streaming Random Patches [^1] ensemble method for regression trains
  each base learner on a subset of features and instances from the
  original data, namely a random patch. This strategy to enforce
  diverse base models is similar to the one in the random forest,
  yet it is not restricted to using decision trees as base learner.
  
  This method is an adaptation of [^2] for regression.
  
  Parameters
  ----------
  model
      The base estimator.
  n_models
      Number of members in the ensemble.
  subspace_size
      Number of features per subset for each classifier where `M` is the
      total number of features.<br/>
      A negative value means `M - subspace_size`.<br/>
      Only applies when using random subspaces or random patches.<br/>
      * If `int` indicates the number of features to use. Valid range [2, M]. <br/>
      * If `float` indicates the percentage of features to use, Valid range (0., 1.]. <br/>
      * 'sqrt' - `sqrt(M)+1`<br/>
      * 'rmsqrt' - Residual from `M-(sqrt(M)+1)`
  training_method
      The training method to use.<br/>
      * 'subspaces' - Random subspaces.<br/>
      * 'resampling' - Resampling.<br/>
      * 'patches' - Random patches.
  lam
      Lambda value for bagging.
  drift_detector
      Drift detector.
  warning_detector
      Warning detector.
  disable_detector
      Option to disable drift detectors:<br/>
      * If `'off'`, detectors are enabled.<br/>
      * If `'drift'`, disables concept drift detection and the background learner.<br/>
      * If `'warning'`, disables the background learner and ensemble members are
       reset if drift is detected.<br/>
  disable_weighted_vote
      If True, disables weighted voting.
  drift_detection_criteria
      The criteria used to track drifts.<br/>
      * 'error' - absolute error.<br/>
      * 'prediction' - predicted target values.
  aggregation_method
      The method to use to aggregate predictions in the ensemble.<br/>
      * 'mean'<br/>
      * 'median'
  seed
      Random number generator seed for reproducibility.
  metric
      The metric to track members performance within the ensemble.
  
  Examples
  --------
  
  >>> from river import ensemble
  >>> from river import evaluate
  >>> from river import metrics
  >>> from river.datasets import synth
  >>> from river import tree
  
  >>> dataset = synth.FriedmanDrift(
  ...     drift_type='gsg',
  ...     position=(350, 750),
  ...     transition_window=200,
  ...     seed=42
  ... ).take(1000)
  
  >>> base_model = tree.HoeffdingTreeRegressor(grace_period=50)
  >>> model = ensemble.SRPRegressor(
  ...     model=base_model,
  ...     training_method="patches",
  ...     n_models=3,
  ...     seed=42
  ... )
  
  >>> metric = metrics.R2()
  
  >>> evaluate.progressive_val_score(dataset, model, metric)
  R2: 0.571117
  
  Notes
  -----
  This implementation uses `n_models=10` as default given the impact on
  processing time. The optimal number of models depends on the data and
  resources available.
  
  References
  ----------
  [^1]: Heitor Gomes, Jacob Montiel, Saulo Martiello Mastelini,
        Bernhard Pfahringer, and Albert Bifet.
        On Ensemble Techniques for Data Stream Regression.
        IJCNN'20. International Joint Conference on Neural Networks. 2020.
  
  [^2]: Heitor Murilo Gomes, Jesse Read, Albert Bifet.
        Streaming Random Patches for Evolving Data Stream Classification.
        IEEE International Conference on Data Mining (ICDM), 2019.
class_docstr_tok: ["Streaming","Random","Patches","ensemble","regressor",".","The","Streaming","Random","Patches","[","^1","]","ensemble","method","for","regression","trains","each","base","learner","on","a","subset","of","features","and","instances","from","the","original","data",",","namely","a","random","patch",".","This","strategy","to","enforce","diverse","base","models","is","similar","to","the","one","in","the","random","forest",",","yet","it","is","not","restricted","to","using","decision","trees","as","base","learner",".","This","method","is","an","adaptation","of","[","^2","]","for","regression",".","Parameters","--","--","--","--","--","model","The","base","estimator",".","n_models","Number","of","members","in","the","ensemble",".","subspace_size","Number","of","features","per","subset","for","each","classifier","where","`","M","`","is","the","total","number","of","features.","<","br\/",">","A","negative","value","means","`","M","-","subspace_size","`",".","<","br\/",">","Only","applies","when","using","random","subspaces","or","random","patches.","<","br\/",">","*","If","`","int","`","indicates","the","number","of","features","to","use",".","Valid","range","[","2",",","M","]",".","<","br\/",">","*","If","`","float","`","indicates","the","percentage","of","features","to","use",",","Valid","range","(","0.",",","1.","]",".","<","br\/",">","*","'sqrt","'","-","`","sqrt","(","M",")","+1","`","<","br\/",">","*","'rmsqrt","'","-","Residual","from","`","M-","(","sqrt","(","M",")","+1",")","`","training_method","The","training","method","to","use.","<","br\/",">","*","'subspaces","'","-","Random","subspaces.","<","br\/",">","*","'resampling","'","-","Resampling.","<","br\/",">","*","'patches","'","-","Random","patches",".","lam","Lambda","value","for","bagging",".","drift_detector","Drift","detector",".","warning_detector","Warning","detector",".","disable_detector","Option","to","disable","drift","detectors",":","<","br\/",">","*","If","`","'off","'","`",",","detectors","are","enabled.","<","br\/",">","*","If","`","'drift","'","`",",","disables","concept","drift","detection","and","the","background","learner.","<","br\/",">","*","If","`","'warning","'","`",",","disables","the","background","learner","and","ensemble","members","are","reset","if","drift","is","detected.","<","br\/",">","disable_weighted_vote","If","True",",","disables","weighted","voting",".","drift_detection_criteria","The","criteria","used","to","track","drifts.","<","br\/",">","*","'error","'","-","absolute","error.","<","br\/",">","*","'prediction","'","-","predicted","target","values",".","aggregation_method","The","method","to","use","to","aggregate","predictions","in","the","ensemble.","<","br\/",">","*","'mean","'","<","br\/",">","*","'median'","seed","Random","number","generator","seed","for","reproducibility",".","metric","The","metric","to","track","members","performance","within","the","ensemble",".","Examples","--","--","--","--",">",">",">","from","river","import","ensemble",">",">",">","from","river","import","evaluate",">",">",">","from","river","import","metrics",">",">",">","from","river.datasets","import","synth",">",">",">","from","river","import","tree",">",">",">","dataset","=","synth.FriedmanDrift","(","...","drift_type='gsg","'",",","...","position=","(","350",",","750",")",",","...","transition_window=200",",","...","seed=42","...",")",".take","(","1000",")",">",">",">","base_model","=","tree.HoeffdingTreeRegressor","(","grace_period=50",")",">",">",">","model","=","ensemble.SRPRegressor","(","...","model=base_model",",","...","training_method=","''","patches","''",",","...","n_models=3",",","...","seed=42","...",")",">",">",">","metric","=","metrics.R2","(",")",">",">",">","evaluate.progressive_val_score","(","dataset",",","model",",","metric",")","R2",":","0.571117","Notes","--","--","-","This","implementation","uses","`","n_models=10","`","as","default","given","the","impact","on","processing","time",".","The","optimal","number","of","models","depends","on","the","data","and","resources","available",".","References","--","--","--","--","--","[","^1","]",":","Heitor","Gomes",",","Jacob","Montiel",",","Saulo","Martiello","Mastelini",",","Bernhard","Pfahringer",",","and","Albert","Bifet",".","On","Ensemble","Techniques","for","Data","Stream","Regression",".","IJCNN'20",".","International","Joint","Conference","on","Neural","Networks",".","2020",".","[","^2","]",":","Heitor","Murilo","Gomes",",","Jesse","Read",",","Albert","Bifet",".","Streaming","Random","Patches","for","Evolving","Data","Stream","Classification",".","IEEE","International","Conference","on","Data","Mining","(","ICDM",")",",","2019","."]
code: def predict_one(self, x, **kwargs):
      y_pred = np.zeros(self.n_models)
      weights = np.ones(self.n_models)
  
      for i, model in enumerate(self.models):
          y_pred[i] = model.predict_one(x, **kwargs)
          if not self.disable_weighted_vote:
              metric_value = model.metric.get()
              weights[i] = metric_value if metric_value >= 0 else 0.0
  
      if self.aggregation_method == self._MEAN:
          if not self.disable_weighted_vote:
              if not self.metric.bigger_is_better:
                  # Invert weights so smaller values have larger influence
                  weights = -(weights - max(weights))
              if sum(weights) == 0:
                  # Average is undefined
                  return 0.0
          return np.average(y_pred, weights=weights)
      else:  # self.aggregation_method == self._MEDIAN:
          return np.median(y_pred)
  
imports: from __future__ import annotations
  import collections
  import itertools
  import math
  import random
  import numpy
  from river import base
  from river.drift import ADWIN
  from river.metrics import MAE, Accuracy
  from river.metrics.base import ClassificationMetric, Metric, RegressionMetric
  from river.tree import HoeffdingTreeClassifier, HoeffdingTreeRegressor
  from river.utils.random import poisson
label_desc: Use image node_id 2 for calling the SRPRegressor obj's underlying member method code with example usage: obj.predict_one(x) and returns: np, np, int