class_docstr: Base Stochastic Gradient Tree (SGT) class.
  
  This class defines the main characteristics that are shared by the different SGT
  implementations.
class_docstr_tok: ["Base","Stochastic","Gradient","Tree","(","SGT",")","class",".","This","class","defines","the","main","characteristics","that","are","shared","by","the","different","SGT","implementations","."]
code: def __init__(
      self,
      loss_func,
      delta,
      grace_period,
      init_pred,
      max_depth,
      lambda_value,
      gamma,
      nominal_attributes,
      feature_quantizer,
  ):
      # What really defines how a SGT works is its loss function
      self.loss_func = loss_func
      self.delta = delta
      self.grace_period = grace_period
      self.init_pred = init_pred
      self.max_depth = max_depth if max_depth else math.inf
  
      if lambda_value < 0.0:
          raise ValueError(
              'Invalid value: "lambda_value" must be positive.'
          )
  
      if gamma < 0.0:
          raise ValueError('Invalid value: "gamma" must be positive.')
  
      self.lambda_value = lambda_value
      self.gamma = gamma
      self.nominal_attributes = (
          set(nominal_attributes) if nominal_attributes else set()
      )
      self.feature_quantizer = (
          feature_quantizer
          if feature_quantizer is not None
          else tree.splitter.StaticQuantizer()
      )
  
      self._root: SGTLeaf | DTBranch = SGTLeaf(
          prediction=self.init_pred
      )
  
      # set used to check whether categorical feature has been already split
      self._split_features = set()
      self._n_splits = 0
      self._n_node_updates = 0
      self._n_observations = 0
  
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 StochasticGradientTree object from inherited base classes: base, abc with example: obj = StochasticGradientTree(loss_func, delta, grace_period, init_pred, max_depth, lambda_value, gamma, nominal_attributes, feature_quantizer)