class_docstr: Extract model data and port a GaussianNB 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
  -------
  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","--","--","--","-","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
      -------
      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)
  
      # Make 'exported' variant:
      if template == enum.Template.EXPORTED:
          tpl_class = tpls.get_template("exported.class")
          out_class = tpl_class.render(**plas)
          encoder.FLOAT_REPR = lambda o: converter(o)
          model_data = dumps(self.model_data, separators=(",", ":"))
          return out_class, model_data
  
      # Make 'attached' variant:
      # Pick templates:
      tpl_double = tpls.get_template("double").render()
      tpl_arr_1 = tpls.get_template("arr[]")
      tpl_arr_2 = tpls.get_template("arr[][]")
      tpl_in_brackets = tpls.get_template("in_brackets")
  
      priors_val = self.model_data.get("priors")
      priors_val_converted = list(map(converter, priors_val))
      priors_str = tpl_arr_1.render(
          type=tpl_double,
          name="priors",
          values=", ".join(priors_val_converted),
          n=len(priors_val_converted),
      )
  
      sigmas_val = self.model_data.get("sigmas")
      sigmas_str = tpl_arr_2.render(
          type=tpl_double,
          name="sigmas",
          values=", ".join(
              list(
                  tpl_in_brackets.render(
                      value=", ".join(list(map(converter, v)))
                  )
                  for v in sigmas_val
              )
          ),
          n=len(sigmas_val),
          m=len(sigmas_val[0]),
      )
  
      thetas_val = self.model_data.get("thetas")
      thetas_str = tpl_arr_2.render(
          type=tpl_double,
          name="thetas",
          values=", ".join(
              list(
                  tpl_in_brackets.render(
                      value=", ".join(list(map(converter, v)))
                  )
                  for v in thetas_val
              )
          ),
          n=len(thetas_val),
          m=len(thetas_val[0]),
      )
  
      plas.update(
          dict(
              priors=priors_str,
              sigmas=sigmas_str,
              thetas=thetas_str,
          )
      )
  
      tpl_class = tpls.get_template("attached.class")
      out_class = tpl_class.render(**plas)
  
      return out_class
  
file_path: sklearn-porter/sklearn_porter/estimator/GaussianNB/__init__.py
imports: from copy import deepcopy
  from json import dumps, encoder
  from typing import Tuple, Union, Callable
  from loguru import logger
  from sklearn.naive_bayes import GaussianNB
  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 GaussianNB 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