<commit_before># -*- coding: utf-8 -*-

from typing import Union, Tuple, Optional
from copy import deepcopy

from sklearn.ensemble.forest import ExtraTreesClassifier \
    as ExtraTreesClassifierClass

from sklearn_porter.estimator.EstimatorApiABC import EstimatorApiABC
from sklearn_porter.estimator.EstimatorBase import EstimatorBase
from sklearn_porter.enums import Method, Language, Template
from sklearn_porter.utils import get_logger


L = get_logger(__name__)


class ExtraTreesClassifier(EstimatorBase, EstimatorApiABC):
    """Extract model data and port an ExtraTreesClassifier classifier."""

    estimator = None  # type: ExtraTreesClassifierClass

    def __init__(self, estimator: ExtraTreesClassifierClass):
        super().__init__(estimator)
        L.info('Create specific estimator `%s`.', self.estimator_name)
        est = self.estimator  # alias

        self.meta_info = dict()
        self.model_data = dict()

    def port(
            self,
            method: Optional[Method] = None,
            language: Optional[Language] = None,
            template: Optional[Template] = None,
            **kwargs
    ) -> Union[str, Tuple[str, str]]:
        """
        Port an estimator.

        Parameters
        ----------
        method : Method
            The required method.
        language : Language
            The required language.
        template : Template
            The required template.
        kwargs

        Returns
        -------
        The ported estimator.
        """
        method, language, template = self.check(
            method=method, language=language, template=template)

        # Arguments:
        kwargs.setdefault('method_name', method.value)
        converter = kwargs.get('converter')

        # Placeholders:
        plas = deepcopy(self.placeholders)  # alias
        plas.update(dict(
            class_name=kwargs.get('class_name'),
            method_name=kwargs.get('method_name'),
        ))
        plas.update(self.meta_info)

        # Templates:
        temps = self._load_templates(language.value.KEY)

        return str(self.estimator)<commit_msg>feature/oop-api-refactoring: Adapt the ExtraTreesClassifier estimator<commit_after># -*- coding: utf-8 -*-

from sklearn.ensemble import ExtraTreesClassifier as ExtraTreesClassifierClass

from sklearn_porter.estimator.EstimatorBase import EstimatorBase
from sklearn_porter.estimator.RandomForestClassifier import \
    RandomForestClassifier
from sklearn_porter.utils import get_logger


L = get_logger(__name__)


class ExtraTreesClassifier(RandomForestClassifier, EstimatorBase):
    """Extract model data and port an ExtraTreesClassifier classifier."""

    estimator = None  # type: ExtraTreesClassifierClass

    def __init__(self, estimator: ExtraTreesClassifierClass):
        super().__init__(estimator)
{'fraction_non_alphanumeric': 0.08831808585503166, 'fraction_numerical': 0.0007037297677691766, 'mean_word_length': 2.8627717391304346, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1459620', 'n_tokens_mistral': 803, 'n_tokens_neox': 774, 'n_words': 182}