# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------------------------
# - Generated by tools/entrypoint_compiler.py: do not edit by hand
"""
CountSelector
"""

__all__ = ["CountSelector"]


from ...entrypoints.transforms_featureselectorbycount import \
    transforms_featureselectorbycount
from ...utils.utils import trace
from ..base_pipeline_item import BasePipelineItem, DefaultSignature


class CountSelector(BasePipelineItem, DefaultSignature):
    """
    Selects the features for which the count of non-default values is
    greater than or equal to a threshold.

    .. remarks::
        When using the count mode in feature selection transform, a feature
        is
        selected if the number of examples have at least the specified count
        examples of non-default values in the feature. The count mode feature
        selection transform is very useful when applied together with a
        categorical
        hash transform (see also, :py:class:`OneHotHashVectorizer
        <nimbusml.feature_extraction.categorical.OneHotHashVectorizer>` ). The
        count feature
        selection can remove those features generated by hash transform that
        have no
        data in the examples.

    :param count: The threshold for count based feature selection. A feature
        is
        selected if and only if at least ``count`` examples have non-default
        value in the feature. The default value is 1.

    :param params: Additional arguments sent to compute engine.

    .. seealso::
        :py:class:`mutualinformation_select
        <nimbusml.feature_selection.MutualInformationSelector>`

    .. index:: feature, selection, count

    Example:
       .. literalinclude:: /../nimbusml/examples/CountSelector.py
              :language: python
    """

    @trace
    def __init__(
            self,
            count=1,
            **params):
        BasePipelineItem.__init__(
            self, type='transform', **params)

        self.count = count

    @property
    def _entrypoint(self):
        return transforms_featureselectorbycount

    @trace
    def _get_node(self, **all_args):

        input_columns = self.input
        if input_columns is None and 'input' in all_args:
            input_columns = all_args['input']
        if 'input' in all_args:
            all_args.pop('input')

        # validate input
        if input_columns is None:
            raise ValueError(
                "'None' input passed when it cannot be none.")

        if not isinstance(input_columns, list):
            raise ValueError(
                "input has to be a list of strings, instead got %s" %
                type(input_columns))

        algo_args = dict(
            column=input_columns,
            count=self.count)

        all_args.update(algo_args)
        return self._entrypoint(**all_args)

# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------------------------
# - Generated by tools/entrypoint_compiler.py: do not edit by hand
"""
CountSelector
"""

__all__ = ["CountSelector"]


from ...entrypoints.transforms_featureselectorbycount import \
    transforms_featureselectorbycount
from ...utils.utils import trace
from ..base_pipeline_item import BasePipelineItem, DefaultSignature


class CountSelector(BasePipelineItem, DefaultSignature):
    """
    Selects the features for which the count of non-default values is
    greater than or equal to a threshold.

    .. remarks::
        When using the count mode in feature selection transform, a feature
        is
        selected if the number of examples have at least the specified count
        examples of non-default values in the feature. The count mode feature
        selection transform is very useful when applied together with a
        categorical
        hash transform (see also, :py:class:`OneHotHashVectorizer
        <nimbusml.feature_extraction.categorical.OneHotHashVectorizer>` ). The
        count feature
        selection can remove those features generated by hash transform that
        have no
        data in the examples.

    :param count: The threshold for count based feature selection. A feature
        is
        selected if and only if at least ``count`` examples have non-default
        value in the feature. The default value is 1.

    :param params: Additional arguments sent to compute engine.

    .. seealso::
        :py:class:`mutualinformation_select
        <nimbusml.feature_selection.MutualInformationSelector>`

    .. index:: feature, selection, count

    Example:
       .. literalinclude:: /../nimbusml/examples/CountSelector.py
              :language: python
    """

    @trace
    def __init__(
            self,
            count=1,
            **params):
        BasePipelineItem.__init__(
            self, type='transform', **params)

        self.count = count

    @property
    def _entrypoint(self):
        return transforms_featureselectorbycount

    @trace
    def _get_node(self, **all_args):

        input_columns = self.input
        if input_columns is None and 'input' in all_args:
            input_columns = all_args['input']
        if 'input' in all_args:
            all_args.pop('input')

        # validate input
        if input_columns is None:
            raise ValueError(
                "'None' input passed when it cannot be none.")

        if not isinstance(input_columns, list):
            raise ValueError(
                "input has to be a list of strings, instead got %s" %
                type(input_columns))

        algo_args = dict(
            column=input_columns,
            count=self.count)

        all_args.update(algo_args)
        return self._entrypoint(**all_args)

# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. # -------------------------------------------------------------------------------------------- # - Generated by tools/entrypoint_compiler.py: do not edit by hand CountSelector Selects the features for which the count of non-default values is     greater than or equal to a threshold.      .. remarks::         When using the count mode in feature selection transform, a feature         is         selected if the number of examples have at least the specified count         examples of non-default values in the feature. The count mode feature         selection transform is very useful when applied together with a         categorical         hash transform (see also, :py:class:`OneHotHashVectorizer         <nimbusml.feature_extraction.categorical.OneHotHashVectorizer>` ). The         count feature         selection can remove those features generated by hash transform that         have no         data in the examples.      :param count: The threshold for count based feature selection. A feature         is         selected if and only if at least ``count`` examples have non-default         value in the feature. The default value is 1.      :param params: Additional arguments sent to compute engine.      .. seealso::         :py:class:`mutualinformation_select         <nimbusml.feature_selection.MutualInformationSelector>`      .. index:: feature, selection, count      Example:        .. literalinclude:: /../nimbusml/examples/CountSelector.py               :language: python # validate input