class_docstr: Extract model data and port an AdaBoostClassifier classifier.
class_docstr_tok: ["Extract","model","data","and","port","an","AdaBoostClassifier","classifier","."]
docstr: Port an estimator.
  
  Parameters
  ----------
  language : Language
      The required language.
  template : Template
      The required template.
  class_name : str
      Change the default class name which will be used in the generated
      output. By default the class name of the passed estimator will be
      used, e.g. `DecisionTreeClassifier`.
  converter : Callable
      Change the default converter of all floating numbers from the model
      data. By default a simple string cast `str(value)` will be used.
  to_json : bool (default: False)
      Return the result as JSON string.
  
  Returns
  -------
  out_class : str
      The ported estimator.
docstr_tok: ["Port","an","estimator",".","Parameters","--","--","--","--","--","language",":","Language","The","required","language",".","template",":","Template","The","required","template",".","class_name",":","str","Change","the","default","class","name","which","will","be","used","in","the","generated","output",".","By","default","the","class","name","of","the","passed","estimator","will","be","used",",","e.g",".","`","DecisionTreeClassifier","`",".","converter",":","Callable","Change","the","default","converter","of","all","floating","numbers","from","the","model","data",".","By","default","a","simple","string","cast","`","str","(","value",")","`","will","be","used",".","to_json",":","bool","(","default",":","False",")","Return","the","result","as","JSON","string",".","Returns","--","--","--","-","out_class",":","str","The","ported","estimator","."]
code: def port(
      self,
      language: enum.Language,
      template: enum.Template,
      class_name: str,
      converter: Callable[[object], str],
      to_json: bool = False,
  ) -> Union[str, Tuple[str, str]]:
      """
      Port an estimator.
  
      Parameters
      ----------
      language : Language
          The required language.
      template : Template
          The required template.
      class_name : str
          Change the default class name which will be used in the generated
          output. By default the class name of the passed estimator will be
          used, e.g. `DecisionTreeClassifier`.
      converter : Callable
          Change the default converter of all floating numbers from the model
          data. By default a simple string cast `str(value)` will be used.
      to_json : bool (default: False)
          Return the result as JSON string.
  
      Returns
      -------
      out_class : str
          The ported estimator.
      """
      # Placeholders:
      plas = deepcopy(self.placeholders)  # alias
      plas.update(
          dict(
              class_name=class_name,
              to_json=to_json,
          )
      )
      plas.update(self.meta_info)
  
      # Templates:
      tpls = self._load_templates(language.value.KEY)
      encoder.FLOAT_REPR = lambda o: converter(o)
  
      # Make 'exported' variant:
      if template == enum.Template.EXPORTED:
          tpl_class = tpls.get_template("exported.class")
          out_class = tpl_class.render(**plas)
          model_data = self.model_data.get("estimators")
          model_data = dumps(model_data, separators=(",", ":"))
          return out_class, model_data
  
      # Make 'attached' variant:
      elif template == enum.Template.ATTACHED:
          tpl_class = tpls.get_template("attached.class")
          tpl_init = tpls.get_template("init")
          model_data = self.model_data.get("estimators")
          model_data = dumps(model_data, separators=(",", ":"))
          plas["model"] = tpl_init.render(
              name="model", value=model_data
          )
          out_class = tpl_class.render(**plas)
          return out_class, model_data
  
      # Make 'combined' variant:
      # Pick templates:
      tpl_indent = tpls.get_template("indent").render()
  
      # Generate functions:
      out_fns = []
      for idx, model_data in enumerate(
          self.model_data.get("estimators")
      ):
          out_fn = self._create_method(
              templates=tpls,
              language=language.value.KEY,
              converter=converter,
              method_index=str(idx),
              class_name=plas.get("class_name"),
              model_data=model_data,
          )
          out_fns.append(out_fn)
      out_fns = "\n".join(out_fns)
  
      # Generate function names:
      tpl_calls = tpls.get_template("combined.method_calls")
      out_calls = []
      for idx in range(self.meta_info.get("n_estimators")):
          plas_copy = deepcopy(plas)
          plas_copy.update(dict(method_index=idx))
          out_call = tpl_calls.render(**plas_copy)
          out_calls.append(out_call)
      out_calls = "\n".join(out_calls)
  
      n_indents = 1
      out_calls = indent(out_calls, n_indents * tpl_indent)
      out_calls = out_calls[(n_indents * len(tpl_indent)) :]
  
      # Make method:
      tpl_method = tpls.get_template("combined.method")
      plas_copy = deepcopy(plas)
      plas_copy.update(dict(methods=out_fns, method_calls=out_calls))
      out_method = tpl_method.render(**plas_copy)
  
      if language in (enum.Language.JAVA, enum.Language.JS):
          n_indents = 1
          out_method = indent(out_method, n_indents * tpl_indent)
          out_method = out_method[(n_indents * len(tpl_indent)) :]
  
      # Make class:
      tpl_class = tpls.get_template("combined.class")
      copy_plas = deepcopy(plas)
      copy_plas.update(dict(method=out_method))
      out_class = tpl_class.render(**copy_plas)
      return out_class
  
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 2 for calling the AdaBoostClassifier obj's underlying member method code with example usage: obj.port(language, template, class_name, converter, to_json) and returns: out_class, out_class,  model_data, out_class,  model_data