class_docstr: Streaming Random Patches ensemble classifier.
  
  The Streaming Random Patches (SRP) [^1] is an ensemble method that
  simulates bagging or random subspaces. The default algorithm uses both
  bagging and random subspaces, namely Random Patches. The default base
  estimator is a Hoeffding Tree, but other base estimators can be used
  (differently from random forest variations).
  
  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 resampling.
  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.
  seed
      Random number generator seed for reproducibility.
  metric
      The metric to track members performance within the ensemble. This
      implementation assumes that larger values are better when using
      weighted votes.
  
  Examples
  --------
  
  >>> from river import ensemble
  >>> from river import evaluate
  >>> from river import metrics
  >>> from river.datasets import synth
  >>> from river import tree
  
  >>> dataset = synth.ConceptDriftStream(
  ...     seed=42,
  ...     position=500,
  ...     width=50
  ... ).take(1000)
  
  >>> base_model = tree.HoeffdingTreeClassifier(
  ...     grace_period=50, delta=0.01,
  ...     nominal_attributes=['age', 'car', 'zipcode']
  ... )
  >>> model = ensemble.SRPClassifier(
  ...     model=base_model, n_models=3, seed=42,
  ... )
  
  >>> metric = metrics.Accuracy()
  
  >>> evaluate.progressive_val_score(dataset, model, metric)
  Accuracy: 71.97%
  
  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 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","classifier",".","The","Streaming","Random","Patches","(","SRP",")","[","^1","]","is","an","ensemble","method","that","simulates","bagging","or","random","subspaces",".","The","default","algorithm","uses","both","bagging","and","random","subspaces",",","namely","Random","Patches",".","The","default","base","estimator","is","a","Hoeffding","Tree",",","but","other","base","estimators","can","be","used","(","differently","from","random","forest","variations",")",".","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","resampling",".","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",".","seed","Random","number","generator","seed","for","reproducibility",".","metric","The","metric","to","track","members","performance","within","the","ensemble",".","This","implementation","assumes","that","larger","values","are","better","when","using","weighted","votes",".","Examples","--","--","--","--",">",">",">","from","river","import","ensemble",">",">",">","from","river","import","evaluate",">",">",">","from","river","import","metrics",">",">",">","from","river.datasets","import","synth",">",">",">","from","river","import","tree",">",">",">","dataset","=","synth.ConceptDriftStream","(","...","seed=42",",","...","position=500",",","...","width=50","...",")",".take","(","1000",")",">",">",">","base_model","=","tree.HoeffdingTreeClassifier","(","...","grace_period=50",",","delta=0.01",",","...","nominal_attributes=","[","'age","'",",","'car","'",",","'zipcode","'","]","...",")",">",">",">","model","=","ensemble.SRPClassifier","(","...","model=base_model",",","n_models=3",",","seed=42",",","...",")",">",">",">","metric","=","metrics.Accuracy","(",")",">",">",">","evaluate.progressive_val_score","(","dataset",",","model",",","metric",")","Accuracy",":","71.97","%","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","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_proba_one(self, x, **kwargs):
      y_pred = collections.Counter()
  
      if not self.models:
          self._init_ensemble(features=list(x.keys()))
          return y_pred
  
      for model in self.models:
          y_proba_temp = model.predict_proba_one(x, **kwargs)
          metric_value = model.metric.get()
          if not self.disable_weighted_vote and metric_value > 0.0:
              y_proba_temp = {
                  k: val * metric_value
                  for k, val in y_proba_temp.items()
              }
          y_pred.update(y_proba_temp)
  
      total = sum(y_pred.values())
      if total > 0:
          return {
              label: proba / total for label, proba in y_pred.items()
          }
      return 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 SRPClassifier obj's underlying member method code with example usage: obj.predict_proba_one(x) and returns: y_pred, y_pred, unknown