class_docstr: Adaptive Model Rules.
  
  AMRules[^1] is a rule-based algorithm for incremental regression tasks. AMRules relies on the
  Hoeffding bound to build its rule set, similarly to Hoeffding Trees. The Variance-Ratio
  heuristic is used to evaluate rules' splits. Moreover, this rule-based regressor has
  additional capacities not usually found in decision trees.
  
  Firstly, each created decision rule has a built-in drift detection mechanism. Every time a
  drift is detected, the affected decision rule is removed. In addition, AMRules' rules also
  have anomaly detection capabilities. After a warm-up period, each rule tests whether or not
  the incoming instances are anomalies. Anomalous instances are not used for training.
  
  Every time no rule is covering an incoming example, a default rule is used to learn
  from it. A rule covers an instance when all of the rule's literals (tests joined by the
  logical operation `and`) match the input case. The default rule is also applied for predicting
  examples not covered by any rules from the rule set.
  
  Parameters
  ----------
  n_min
      The total weight that must be observed by a rule between expansion attempts.
  delta
      The split test significance. The split confidence is given by `1 - delta`.
  tau
      The tie-breaking threshold.
  pred_type
      The prediction strategy used by the decision rules. Can be either:</br>
      - `"mean"`: outputs the target mean within the partitions defined by the decision
      rules.</br>
      - `"model"`: always use instances of the model passed `pred_model` to make
      predictions.</br>
      - `"adaptive"`: dynamically selects between "mean" and "model" for each incoming example.
      The most accurate option at the moment will be used.
  pred_model
      The regression model that will be replicated for every rule when `pred_type` is either
      `"model"` or `"adaptive"`.
  splitter
      The Splitter or Attribute Observer (AO) used to monitor the class statistics of numeric
      features and perform splits. Splitters are available in the `tree.splitter` module.
      Different splitters are available for classification and regression tasks. Classification
      and regression splitters can be distinguished by their property `is_target_class`.
      This is an advanced option. Special care must be taken when choosing different splitters.
      By default, `tree.splitter.TEBSTSplitter` is used if `splitter` is `None`.
  drift_detector
      The drift detection model that is used by each rule. Care must be taken to avoid the
      triggering of too many false alarms or delaying too much the concept drift detection.
      By default, `drift.ADWIN` is used if `drift_detector` is `None`.
  fading_factor
      The exponential decaying factor applied to the learning models' absolute errors, that
      are monitored if `pred_type='adaptive'`. Must be between `0` and `1`. The closer
      to `1`, the more importance is going to be given to past observations. On the other hand,
      if its value approaches `0`, the recent observed errors are going to have more influence
      on the final decision.
  anomaly_threshold
      The threshold below which instances will be considered anomalies by the rules.
  m_min
      The minimum total weight a rule must observe before it starts to skip anomalous
      instances during training.
  ordered_rule_set
      If `True`, only the first rule that covers an instance will be used for training or
      prediction. If `False`, all the rules covering an instance will be updated during
      training, and the predictions for an instance will be the average prediction of all
      rules covering that example.
  min_samples_split
      The minimum number of samples each partition of a binary split candidate must have
      to be considered valid.
  
  Notes
  -----
  AMRules treats all the non-numerical inputs as nominal features. All instances of
  `numbers.Number` will be treated as continuous, even if they represent integer categories.
  When using nominal features, `pred_type` should be set to "mean", otherwise errors will be
  thrown while trying to update the underlying rules' prediction models. Prediction strategies
  other than "mean" can be used, as long as the prediction model passed to `pred_model` supports
  nominal features.
  
  Raises
  ------
  TypeError
      If one or more input features are non-numeric and the selected `pred_model` is either
      "model" or "adaptive".
  
  Examples
  --------
  >>> from river import datasets
  >>> from river import drift
  >>> from river import evaluate
  >>> from river import metrics
  >>> from river import preprocessing
  >>> from river import rules
  
  >>> dataset = datasets.TrumpApproval()
  
  >>> model = (
  ...     preprocessing.StandardScaler() |
  ...     rules.AMRules(
  ...         delta=0.01,
  ...         n_min=50,
  ...         drift_detector=drift.ADWIN()
  ...     )
  ... )
  
  >>> metric = metrics.MAE()
  
  >>> evaluate.progressive_val_score(dataset, model, metric)
  MAE: 1.119553
  
  References
  ----------
  [^1]: Duarte, J., Gama, J. and Bifet, A., 2016. Adaptive model rules from high-speed data
  streams. ACM Transactions on Knowledge Discovery from Data (TKDD), 10(3), pp.1-22.
class_docstr_tok: ["Adaptive","Model","Rules",".","AMRules","[","^1","]","is","a","rule-based","algorithm","for","incremental","regression","tasks",".","AMRules","relies","on","the","Hoeffding","bound","to","build","its","rule","set",",","similarly","to","Hoeffding","Trees",".","The","Variance-Ratio","heuristic","is","used","to","evaluate","rules","'","splits",".","Moreover",",","this","rule-based","regressor","has","additional","capacities","not","usually","found","in","decision","trees",".","Firstly",",","each","created","decision","rule","has","a","built-in","drift","detection","mechanism",".","Every","time","a","drift","is","detected",",","the","affected","decision","rule","is","removed",".","In","addition",",","AMRules","'","rules","also","have","anomaly","detection","capabilities",".","After","a","warm-up","period",",","each","rule","tests","whether","or","not","the","incoming","instances","are","anomalies",".","Anomalous","instances","are","not","used","for","training",".","Every","time","no","rule","is","covering","an","incoming","example",",","a","default","rule","is","used","to","learn","from","it",".","A","rule","covers","an","instance","when","all","of","the","rule","'s","literals","(","tests","joined","by","the","logical","operation","`","and","`",")","match","the","input","case",".","The","default","rule","is","also","applied","for","predicting","examples","not","covered","by","any","rules","from","the","rule","set",".","Parameters","--","--","--","--","--","n_min","The","total","weight","that","must","be","observed","by","a","rule","between","expansion","attempts",".","delta","The","split","test","significance",".","The","split","confidence","is","given","by","`","1","-","delta","`",".","tau","The","tie-breaking","threshold",".","pred_type","The","prediction","strategy","used","by","the","decision","rules",".","Can","be","either",":","<","\/br",">","-","`","``","mean","''","`",":","outputs","the","target","mean","within","the","partitions","defined","by","the","decision","rules.","<","\/br",">","-","`","``","model","''","`",":","always","use","instances","of","the","model","passed","`","pred_model","`","to","make","predictions.","<","\/br",">","-","`","``","adaptive","''","`",":","dynamically","selects","between","``","mean","''","and","``","model","''","for","each","incoming","example",".","The","most","accurate","option","at","the","moment","will","be","used",".","pred_model","The","regression","model","that","will","be","replicated","for","every","rule","when","`","pred_type","`","is","either","`","``","model","''","`","or","`","``","adaptive","''","`",".","splitter","The","Splitter","or","Attribute","Observer","(","AO",")","used","to","monitor","the","class","statistics","of","numeric","features","and","perform","splits",".","Splitters","are","available","in","the","`","tree.splitter","`","module",".","Different","splitters","are","available","for","classification","and","regression","tasks",".","Classification","and","regression","splitters","can","be","distinguished","by","their","property","`","is_target_class","`",".","This","is","an","advanced","option",".","Special","care","must","be","taken","when","choosing","different","splitters",".","By","default",",","`","tree.splitter.TEBSTSplitter","`","is","used","if","`","splitter","`","is","`","None","`",".","drift_detector","The","drift","detection","model","that","is","used","by","each","rule",".","Care","must","be","taken","to","avoid","the","triggering","of","too","many","false","alarms","or","delaying","too","much","the","concept","drift","detection",".","By","default",",","`","drift.ADWIN","`","is","used","if","`","drift_detector","`","is","`","None","`",".","fading_factor","The","exponential","decaying","factor","applied","to","the","learning","models","'","absolute","errors",",","that","are","monitored","if","`","pred_type='adaptive","'","`",".","Must","be","between","`","0","`","and","`","1","`",".","The","closer","to","`","1","`",",","the","more","importance","is","going","to","be","given","to","past","observations",".","On","the","other","hand",",","if","its","value","approaches","`","0","`",",","the","recent","observed","errors","are","going","to","have","more","influence","on","the","final","decision",".","anomaly_threshold","The","threshold","below","which","instances","will","be","considered","anomalies","by","the","rules",".","m_min","The","minimum","total","weight","a","rule","must","observe","before","it","starts","to","skip","anomalous","instances","during","training",".","ordered_rule_set","If","`","True","`",",","only","the","first","rule","that","covers","an","instance","will","be","used","for","training","or","prediction",".","If","`","False","`",",","all","the","rules","covering","an","instance","will","be","updated","during","training",",","and","the","predictions","for","an","instance","will","be","the","average","prediction","of","all","rules","covering","that","example",".","min_samples_split","The","minimum","number","of","samples","each","partition","of","a","binary","split","candidate","must","have","to","be","considered","valid",".","Notes","--","--","-","AMRules","treats","all","the","non-numerical","inputs","as","nominal","features",".","All","instances","of","`","numbers.Number","`","will","be","treated","as","continuous",",","even","if","they","represent","integer","categories",".","When","using","nominal","features",",","`","pred_type","`","should","be","set","to","``","mean","''",",","otherwise","errors","will","be","thrown","while","trying","to","update","the","underlying","rules","'","prediction","models",".","Prediction","strategies","other","than","``","mean","''","can","be","used",",","as","long","as","the","prediction","model","passed","to","`","pred_model","`","supports","nominal","features",".","Raises","--","--","--","TypeError","If","one","or","more","input","features","are","non-numeric","and","the","selected","`","pred_model","`","is","either","``","model","''","or","``","adaptive","''",".","Examples","--","--","--","--",">",">",">","from","river","import","datasets",">",">",">","from","river","import","drift",">",">",">","from","river","import","evaluate",">",">",">","from","river","import","metrics",">",">",">","from","river","import","preprocessing",">",">",">","from","river","import","rules",">",">",">","dataset","=","datasets.TrumpApproval","(",")",">",">",">","model","=","(","...","preprocessing.StandardScaler","(",")","|","...","rules.AMRules","(","...","delta=0.01",",","...","n_min=50",",","...","drift_detector=drift.ADWIN","(",")","...",")","...",")",">",">",">","metric","=","metrics.MAE","(",")",">",">",">","evaluate.progressive_val_score","(","dataset",",","model",",","metric",")","MAE",":","1.119553","References","--","--","--","--","--","[","^1","]",":","Duarte",",","J.",",","Gama",",","J.","and","Bifet",",","A.",",","2016",".","Adaptive","model","rules","from","high-speed","data","streams",".","ACM","Transactions","on","Knowledge","Discovery","from","Data","(","TKDD",")",",","10","(","3",")",",","pp.1-22","."]
code: def predict_one(self, x: dict) -> base.typing.RegTarget:
      y_pred = 0
      hits = 0
  
      for rule in self._rules.values():
          if rule.covers(x):
              y_pred += rule.predict_one(x)
              hits += 1
  
              if self.ordered_rule_set:
                  break
  
      if hits > 0:
          return y_pred / hits  # type: ignore
      else:
          return self._default_rule.predict_one(x)
  
imports: from __future__ import annotations
  import collections
  import functools
  import io
  import math
  import typing
  from river import anomaly, base, drift, linear_model, stats
  from river.tree import split_criterion
  from river.tree import splitter
  from .base import HoeffdingRule
label_desc: Use image node_id 8 for calling the AMRules obj's underlying member method code with example usage: obj.predict_one(x) and returns: unknown, self