class_docstr: Extract model data and port an AdaBoostClassifier classifier.
class_docstr_tok: ["Extract","model","data","and","port","an","AdaBoostClassifier","classifier","."]
code: def __init__(self, estimator: AdaBoostClassifierClass):
      super().__init__(estimator)
      L.info("Create specific estimator `%s`.", self.estimator_name)
      est = self.estimator  # alias
  
      # Check the used algorithm type:
      if est.algorithm != "SAMME.R":
          msg = "The used algorithm `{}` is not supported yet."
          msg = msg.format(est.algorithm)
          raise exception.NotSupportedYetError(msg)
  
      # Check type of base estimators:
      if not isinstance(est.base_estimator_, DecisionTreeClassifier):
          msg = "The used base estimator `{}` is not supported yet."
          msg = msg.format(est.base_estimator.__class__.__qualname__)
          raise exception.NotSupportedYetError(msg)
  
      # Ignore estimators with zero weight:
      estimators = []
      for idx in range(est.n_estimators):
          if est.estimator_weights_[idx] > 0:
              estimators.append(est.estimators_[idx])
      n_estimators = len(estimators)
  
      self.meta_info = dict(
          n_classes=est.n_classes_,
          n_features=est.estimators_[0].n_features_,
          n_estimators=n_estimators,
      )
      L.info("Meta info (keys): {}".format(self.meta_info.keys()))
      L.opt(lazy=True).debug("Meta info: {}".format(self.meta_info))
  
      self.model_data["estimators"] = []
      for e in estimators:
          self.model_data["estimators"].append(
              dict(
                  lefts=e.tree_.children_left.tolist(),
                  rights=e.tree_.children_right.tolist(),
                  thresholds=e.tree_.threshold.tolist(),
                  classes=[c[0] for c in e.tree_.value.tolist()],
                  indices=e.tree_.feature.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/AdaBoostClassifier/__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.ensemble.weight_boosting import AdaBoostClassifier
  from sklearn.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 AdaBoostClassifier object from inherited base classes: EstimatorBase, EstimatorApiABC with example: obj = AdaBoostClassifier(estimator)