docstr: TAO: Alternating optimization of decision trees, with application to learning sparse oblique trees (Neurips 2018)
  https://proceedings.neurips.cc/paper/2018/hash/185c29dc24325934ee377cfda20e414c-Abstract.html
  Note: this implementation learns single-feature splits rather than oblique trees.
  
  Currently supports
  - given a CART tree, posthoc improve it with TAO
      - also works with HSTreeCV
  
  Todo
  - update bottom to top otherwise input points don't get updated
  - update leaf nodes
  - support regression
  - support FIGS
  - support error-weighting
  - support oblique trees
      - support generic models at decision node
      - support pruning (e.g. if weights -> 0, then remove a node)
  - support classifiers in leaves
  
  Parameters
  ----------
  
  model_type: str
      'CART' or 'FIGS'
  
  n_iters
      Number of iterations to run TAO
  
  model_args
      Arguments to pass to the model
  
  randomize_tree
      Whether to randomize the tree before each iteration
  
  min_node_samples_tao: int
      Minimum number of samples in a node to apply tao
  
  min_leaf_samples_tao: int
  
  node_model: str
      'stump' or 'linear'
  
  reg_param
      Regularization parameter for node-wise linear model (if node_model is 'linear')
  
  verbose: int
      Verbosity level
docstr_tok: ["TAO",":","Alternating","optimization","of","decision","trees",",","with","application","to","learning","sparse","oblique","trees","(","Neurips","2018",")","https",":","\/\/proceedings.neurips.cc\/paper\/2018\/hash\/185c29dc24325934ee377cfda20e414c-Abstract.html","Note",":","this","implementation","learns","single-feature","splits","rather","than","oblique","trees",".","Currently","supports","-","given","a","CART","tree",",","posthoc","improve","it","with","TAO","-","also","works","with","HSTreeCV","Todo","-","update","bottom","to","top","otherwise","input","points","do","n't","get","updated","-","update","leaf","nodes","-","support","regression","-","support","FIGS","-","support","error-weighting","-","support","oblique","trees","-","support","generic","models","at","decision","node","-","support","pruning","(","e.g",".","if","weights","-",">","0",",","then","remove","a","node",")","-","support","classifiers","in","leaves","Parameters","--","--","--","--","--","model_type",":","str","'CART","'","or","'FIGS'","n_iters","Number","of","iterations","to","run","TAO","model_args","Arguments","to","pass","to","the","model","randomize_tree","Whether","to","randomize","the","tree","before","each","iteration","min_node_samples_tao",":","int","Minimum","number","of","samples","in","a","node","to","apply","tao","min_leaf_samples_tao",":","int","node_model",":","str","'stump","'","or","'linear'","reg_param","Regularization","parameter","for","node-wise","linear","model","(","if","node_model","is","'linear","'",")","verbose",":","int","Verbosity","level"]
code: def __init__(
      self,
      model_type: str = "CART",
      n_iters: int = 20,
      model_args: dict = {"max_leaf_nodes": 15},
      randomize_tree=False,
      update_scoring="accuracy",
      min_node_samples_tao=3,
      min_leaf_samples_tao=2,
      node_model="stump",
      node_model_args: dict = {},
      reg_param: float = 1e-3,
      weight_errors: bool = False,
      verbose: int = 0,
  ):
      """TAO: Alternating optimization of decision trees, with application to learning sparse oblique trees (Neurips 2018)
      https://proceedings.neurips.cc/paper/2018/hash/185c29dc24325934ee377cfda20e414c-Abstract.html
      Note: this implementation learns single-feature splits rather than oblique trees.
  
      Currently supports
      - given a CART tree, posthoc improve it with TAO
          - also works with HSTreeCV
  
      Todo
      - update bottom to top otherwise input points don't get updated
      - update leaf nodes
      - support regression
      - support FIGS
      - support error-weighting
      - support oblique trees
          - support generic models at decision node
          - support pruning (e.g. if weights -> 0, then remove a node)
      - support classifiers in leaves
  
      Parameters
      ----------
  
      model_type: str
          'CART' or 'FIGS'
  
      n_iters
          Number of iterations to run TAO
  
      model_args
          Arguments to pass to the model
  
      randomize_tree
          Whether to randomize the tree before each iteration
  
      min_node_samples_tao: int
          Minimum number of samples in a node to apply tao
  
      min_leaf_samples_tao: int
  
      node_model: str
          'stump' or 'linear'
  
      reg_param
          Regularization parameter for node-wise linear model (if node_model is 'linear')
  
      verbose: int
          Verbosity level
      """
      super().__init__()
      self.model_type = model_type
      self.n_iters = n_iters
      self.model_args = model_args
      self.randomize_tree = randomize_tree
      self.update_scoring = update_scoring
      self.min_node_samples_tao = min_node_samples_tao
      self.min_leaf_samples_tao = min_leaf_samples_tao
      self.node_model = node_model
      self.node_model_args = node_model_args
      self.reg_param = reg_param
      self.weight_errors = weight_errors
      self.verbose = verbose
      self._init_prediction_task()
  
imports: import random
  from copy import deepcopy
  from queue import deque
  import numpy
  from mlxtend.classifier import LogisticRegression
  from sklearn import datasets
  from sklearn.base import BaseEstimator, RegressorMixin, ClassifierMixin
  from sklearn.linear_model import LinearRegression
  from sklearn.metrics import get_scorer
  from sklearn.model_selection import train_test_split
  from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor, export_text
  from sklearn.utils import check_X_y
  from imodels.util.arguments import check_fit_arguments
label_desc: Use image node_id 1 to create a new TaoTree object from inherited base classes: BaseEstimator with example: obj = TaoTree(model_type, n_iters, model_args, randomize_tree, update_scoring, min_node_samples_tao, min_leaf_samples_tao, node_model, node_model_args, reg_param, weight_errors, verbose)