class_docstr: Extract model data and port a DecisionTreeClassifier classifier.
class_docstr_tok: ["Extract","model","data","and","port","a","DecisionTreeClassifier","classifier","."]
code: def __init__(self, estimator: DecisionTreeClassifierClass):
      super().__init__(estimator)
      L.info("Create specific estimator `%s`.", self.estimator_name)
      est = self.estimator  # alias
  
      # Is the estimator fitted?
      try:
          getattr(est, "n_features_")  # for sklearn >  0.19
          getattr(est.tree_, "value")  # for sklearn <= 0.18
      except AttributeError:
          raise exception.NotFittedEstimatorError(self.estimator_name)
  
      # Extract and save meta information:
      self.meta_info = dict(
          n_features=est.n_features_,
          n_classes=len(est.tree_.value.tolist()[0][0]),
      )
      L.info("Meta info (keys): {}".format(self.meta_info.keys()))
      L.opt(lazy=True).debug("Meta info: {}".format(self.meta_info))
  
      # Extract and save model data:
      self.model_data = dict(
          lefts=est.tree_.children_left.tolist(),
          rights=est.tree_.children_right.tolist(),
          thresholds=est.tree_.threshold.tolist(),
          indices=est.tree_.feature.tolist(),
          classes=[
              [int(c) for c in l[0]] for l in est.tree_.value.tolist()
          ],
      )
      L.info("Model data (keys): {}".format(self.model_data.keys()))
      L.opt(lazy=True).debug("Model data: {}".format(self.model_data))
  
file_path: sklearn-porter/sklearn_porter/estimator/DecisionTreeClassifier/__init__.py
imports: from copy import deepcopy
  from json import dumps, encoder
  from textwrap import indent
  from typing import Callable, Tuple, Union
  from jinja2 import Environment
  from loguru import logger
  from sklearn.tree.tree import DecisionTreeClassifier
  from sklearn_porter import enums
  from sklearn_porter import exceptions
  from sklearn_porter.estimator.EstimatorApiABC import EstimatorApiABC
  from sklearn_porter.estimator.EstimatorBase import EstimatorBase
label_desc: Use image node_id 1 to create a new DecisionTreeClassifier object from inherited base classes: EstimatorBase, EstimatorApiABC with example: obj = DecisionTreeClassifier(estimator)