class_docstr: Stochastic Gradient Tree for regression.
  
  Incremental decision tree regressor that minimizes the mean square error to guide its growth.
  
  Stochastic Gradient Trees (SGT) directly minimize a loss function to guide tree growth and
  update their predictions. Thus, they differ from other incrementally tree learners that do
  not directly optimize the loss, but a data impurity-related heuristic.
  
  Parameters
  ----------
  delta
      Define the significance level of the F-tests performed to decide upon creating splits
      or updating predictions.
  grace_period
      Interval between split attempts or prediction updates.
  init_pred
      Initial value predicted by the tree.
  max_depth
      The maximum depth the tree might reach. If set to `None`, the trees will grow
      indefinitely.
  lambda_value
      Positive float value used to impose a penalty over the tree's predictions and force
      them to become smaller. The greater the lambda value, the more constrained are the
      predictions.
  gamma
      Positive float value used to impose a penalty over the tree's splits and force them to
      be avoided when possible. The greater the gamma value, the smaller the chance of a
      split occurring.
  nominal_attributes
      List with identifiers of the nominal attributes. If None, all features containing
      numbers are assumed to be numeric.
  feature_quantizer
      The algorithm used to quantize numeric features. Either a static quantizer (as in the
      original implementation) or a dynamic quantizer can be used. The correct choice and setup
      of the feature quantizer is a crucial step to determine the performance of SGTs.
      Feature quantizers are akin to the attribute observers used in Hoeffding Trees. By
      default, an instance of `tree.splitter.StaticQuantizer` (with default parameters) is
      used if this parameter is not set.
  
  Examples
  --------
  >>> from river import datasets
  >>> from river import evaluate
  >>> from river import metrics
  >>> from river import tree
  
  >>> dataset = datasets.TrumpApproval()
  >>> model = tree.SGTRegressor(
  ...     delta=0.01,
  ...     lambda_value=0.01,
  ...     grace_period=20,
  ...     feature_quantizer=tree.splitter.DynamicQuantizer(std_prop=0.1)
  ... )
  >>> metric = metrics.MAE()
  
  >>> evaluate.progressive_val_score(dataset, model, metric)
  MAE: 1.721818
  
  Notes
  -----
  This implementation enhances the original proposal [^1] by using an incremental strategy to
  discretize numerical features dynamically, rather than relying on a calibration set and
  parameterized number of bins. The strategy used is an adaptation of the Quantization Observer
  (QO) [^2]. Different bin size setting policies are available for selection.
  They directly related to number of split candidates the tree is going to explore, and thus,
  how accurate its split decisions are going to be. Besides, the number of stored bins per
  feature is directly related to the tree's memory usage and runtime.
  
  References
  ----------
  [^1]: Gouk, H., Pfahringer, B., & Frank, E. (2019, October). Stochastic Gradient Trees.
  In Asian Conference on Machine Learning (pp. 1094-1109).
  [^2]: Mastelini, S.M. and de Leon Ferreira, A.C.P., 2021. Using dynamical quantization
  to perform split attempts in online tree regressors. Pattern Recognition Letters.
class_docstr_tok: ["Stochastic","Gradient","Tree","for","regression",".","Incremental","decision","tree","regressor","that","minimizes","the","mean","square","error","to","guide","its","growth",".","Stochastic","Gradient","Trees","(","SGT",")","directly","minimize","a","loss","function","to","guide","tree","growth","and","update","their","predictions",".","Thus",",","they","differ","from","other","incrementally","tree","learners","that","do","not","directly","optimize","the","loss",",","but","a","data","impurity-related","heuristic",".","Parameters","--","--","--","--","--","delta","Define","the","significance","level","of","the","F-tests","performed","to","decide","upon","creating","splits","or","updating","predictions",".","grace_period","Interval","between","split","attempts","or","prediction","updates",".","init_pred","Initial","value","predicted","by","the","tree",".","max_depth","The","maximum","depth","the","tree","might","reach",".","If","set","to","`","None","`",",","the","trees","will","grow","indefinitely",".","lambda_value","Positive","float","value","used","to","impose","a","penalty","over","the","tree","'s","predictions","and","force","them","to","become","smaller",".","The","greater","the","lambda","value",",","the","more","constrained","are","the","predictions",".","gamma","Positive","float","value","used","to","impose","a","penalty","over","the","tree","'s","splits","and","force","them","to","be","avoided","when","possible",".","The","greater","the","gamma","value",",","the","smaller","the","chance","of","a","split","occurring",".","nominal_attributes","List","with","identifiers","of","the","nominal","attributes",".","If","None",",","all","features","containing","numbers","are","assumed","to","be","numeric",".","feature_quantizer","The","algorithm","used","to","quantize","numeric","features",".","Either","a","static","quantizer","(","as","in","the","original","implementation",")","or","a","dynamic","quantizer","can","be","used",".","The","correct","choice","and","setup","of","the","feature","quantizer","is","a","crucial","step","to","determine","the","performance","of","SGTs",".","Feature","quantizers","are","akin","to","the","attribute","observers","used","in","Hoeffding","Trees",".","By","default",",","an","instance","of","`","tree.splitter.StaticQuantizer","`","(","with","default","parameters",")","is","used","if","this","parameter","is","not","set",".","Examples","--","--","--","--",">",">",">","from","river","import","datasets",">",">",">","from","river","import","evaluate",">",">",">","from","river","import","metrics",">",">",">","from","river","import","tree",">",">",">","dataset","=","datasets.TrumpApproval","(",")",">",">",">","model","=","tree.SGTRegressor","(","...","delta=0.01",",","...","lambda_value=0.01",",","...","grace_period=20",",","...","feature_quantizer=tree.splitter.DynamicQuantizer","(","std_prop=0.1",")","...",")",">",">",">","metric","=","metrics.MAE","(",")",">",">",">","evaluate.progressive_val_score","(","dataset",",","model",",","metric",")","MAE",":","1.721818","Notes","--","--","-","This","implementation","enhances","the","original","proposal","[","^1","]","by","using","an","incremental","strategy","to","discretize","numerical","features","dynamically",",","rather","than","relying","on","a","calibration","set","and","parameterized","number","of","bins",".","The","strategy","used","is","an","adaptation","of","the","Quantization","Observer","(","QO",")","[","^2","]",".","Different","bin","size","setting","policies","are","available","for","selection",".","They","directly","related","to","number","of","split","candidates","the","tree","is","going","to","explore",",","and","thus",",","how","accurate","its","split","decisions","are","going","to","be",".","Besides",",","the","number","of","stored","bins","per","feature","is","directly","related","to","the","tree","'s","memory","usage","and","runtime",".","References","--","--","--","--","--","[","^1","]",":","Gouk",",","H.",",","Pfahringer",",","B.",",","&","Frank",",","E.","(","2019",",","October",")",".","Stochastic","Gradient","Trees",".","In","Asian","Conference","on","Machine","Learning","(","pp",".","1094-1109",")",".","[","^2","]",":","Mastelini",",","S.M",".","and","de","Leon","Ferreira",",","A.C.P.",",","2021",".","Using","dynamical","quantization","to","perform","split","attempts","in","online","tree","regressors",".","Pattern","Recognition","Letters","."]
code: def __init__(
      self,
      delta: float = 1e-7,
      grace_period: int = 200,
      init_pred: float = 0.0,
      max_depth: int | None = None,
      lambda_value: float = 0.1,
      gamma: float = 1.0,
      nominal_attributes: list | None = None,
      feature_quantizer: tree.splitter.Quantizer | None = None,
  ):
      super().__init__(
          loss_func=SquaredErrorLoss(),
          delta=delta,
          grace_period=grace_period,
          init_pred=init_pred,
          max_depth=max_depth,
          lambda_value=lambda_value,
          gamma=gamma,
          nominal_attributes=nominal_attributes,
          feature_quantizer=feature_quantizer,
      )
  
imports: from __future__ import annotations
  import abc
  import math
  from scipy.stats import f
  from river import base, tree
  from .losses import BinaryCrossEntropyLoss, SquaredErrorLoss
  from .nodes.branch import DTBranch, NominalMultiwayBranch, NumericBinaryBranch
  from .nodes.sgt_nodes import SGTLeaf
  from .utils import BranchFactory, GradHessMerit
label_desc: Use image node_id 1 to create a new SGTRegressor object from inherited base classes: StochasticGradientTree, base with example: obj = SGTRegressor(delta, grace_period, init_pred, max_depth, lambda_value, gamma, nominal_attributes, feature_quantizer)