docstr: HSTree (Tree with hierarchical shrinkage applied).
  Hierarchical shinkage is an extremely fast post-hoc regularization method which works on any decision tree (or tree-based ensemble, such as Random Forest).
  It does not modify the tree structure, and instead regularizes the tree by shrinking the prediction over each node towards the sample means of its ancestors (using a single regularization parameter).
  Experiments over a wide variety of datasets show that hierarchical shrinkage substantially increases the predictive performance of individual decision trees and decision-tree ensembles.
  https://arxiv.org/abs/2202.00858
  
  Params
  ------
  estimator_: sklearn tree or tree ensemble model (e.g. RandomForest or GradientBoosting)
  
  reg_param: float
      Higher is more regularization (can be arbitrarily large, should not be < 0)
  
  shrinkage_scheme: str
      Experimental: Used to experiment with different forms of shrinkage. options are:
          (i) node_based shrinks based on number of samples in parent node
          (ii) leaf_based only shrinks leaf nodes based on number of leaf samples
          (iii) constant shrinks every node by a constant lambda
docstr_tok: ["HSTree","(","Tree","with","hierarchical","shrinkage","applied",")",".","Hierarchical","shinkage","is","an","extremely","fast","post-hoc","regularization","method","which","works","on","any","decision","tree","(","or","tree-based","ensemble",",","such","as","Random","Forest",")",".","It","does","not","modify","the","tree","structure",",","and","instead","regularizes","the","tree","by","shrinking","the","prediction","over","each","node","towards","the","sample","means","of","its","ancestors","(","using","a","single","regularization","parameter",")",".","Experiments","over","a","wide","variety","of","datasets","show","that","hierarchical","shrinkage","substantially","increases","the","predictive","performance","of","individual","decision","trees","and","decision-tree","ensembles",".","https",":","\/\/arxiv.org\/abs\/2202.00858","Params","--","--","--","estimator_",":","sklearn","tree","or","tree","ensemble","model","(","e.g",".","RandomForest","or","GradientBoosting",")","reg_param",":","float","Higher","is","more","regularization","(","can","be","arbitrarily","large",",","should","not","be","<","0",")","shrinkage_scheme",":","str","Experimental",":","Used","to","experiment","with","different","forms","of","shrinkage",".","options","are",":","(","i",")","node_based","shrinks","based","on","number","of","samples","in","parent","node","(","ii",")","leaf_based","only","shrinks","leaf","nodes","based","on","number","of","leaf","samples","(","iii",")","constant","shrinks","every","node","by","a","constant","lambda"]
code: def __init__(
      self,
      estimator_: BaseEstimator,
      reg_param: float = 1,
      shrinkage_scheme_: str = "node_based",
  ):
      """HSTree (Tree with hierarchical shrinkage applied).
      Hierarchical shinkage is an extremely fast post-hoc regularization method which works on any decision tree (or tree-based ensemble, such as Random Forest).
      It does not modify the tree structure, and instead regularizes the tree by shrinking the prediction over each node towards the sample means of its ancestors (using a single regularization parameter).
      Experiments over a wide variety of datasets show that hierarchical shrinkage substantially increases the predictive performance of individual decision trees and decision-tree ensembles.
      https://arxiv.org/abs/2202.00858
  
      Params
      ------
      estimator_: sklearn tree or tree ensemble model (e.g. RandomForest or GradientBoosting)
  
      reg_param: float
          Higher is more regularization (can be arbitrarily large, should not be < 0)
  
      shrinkage_scheme: str
          Experimental: Used to experiment with different forms of shrinkage. options are:
              (i) node_based shrinks based on number of samples in parent node
              (ii) leaf_based only shrinks leaf nodes based on number of leaf samples
              (iii) constant shrinks every node by a constant lambda
      """
      super().__init__()
      self.reg_param = reg_param
      # print('est', estimator_)
      self.estimator_ = estimator_
      self.shrinkage_scheme_ = shrinkage_scheme_
      self._init_prediction_task()
  
      if checks.check_is_fitted(self.estimator_):
          self._shrink()
  
imports: from copy import deepcopy
  from typing import List
  import numpy
  from sklearn import datasets
  from sklearn.base import BaseEstimator
  from sklearn.metrics import r2_score
  from sklearn.model_selection import cross_val_score
  from sklearn.model_selection import train_test_split
  from sklearn.tree import DecisionTreeRegressor
  from imodels.util import checks
label_desc: Use image node_id 1 to create a new HSFIGS object  with example: obj = HSFIGS(estimator_, reg_param, shrinkage_scheme_)