<commit_before>"""
Created on 11 Mar 2019

@author: <NAME> (<EMAIL>)
"""

from scs_core.data.regression import Regression


# --------------------------------------------------------------------------------------------------------------------

class CatagoricalRegression(Regression):
    """
    classdocs
    """

    # ----------------------------------------------------------------------------------------------------------------

    def __init__(self):
        """
        Constructor
        """
        self.__data = set()


    def __len__(self):
        return len(self.__data)


    # ----------------------------------------------------------------------------------------------------------------

    def has_midpoint(self):
        return len(self) > 0


    def has_regression(self):
        return len(self) > 0


    def append(self, _, value):
        self.__data.add(value)


    def reset(self):
        self.__data = set()


    # ----------------------------------------------------------------------------------------------------------------

    def midpoint(self, ndigits=None):
        if len(self) != 1:
            return None, None

        return None, next(iter(self.__data))


    # ----------------------------------------------------------------------------------------------------------------

    def min(self, ndigits=None):
        ordered = sorted(self.__data)

        return ordered[0]


    def max(self, ndigits=None):
        ordered = sorted(self.__data)

        return ordered[-1]


    # ----------------------------------------------------------------------------------------------------------------

    def __str__(self, *args, **kwargs):
        return "CatagoricalRegression:{data:%s}" %  self.__data<commit_msg>Added CategoricalRegression handling to SampleAggregate.<commit_after>"""
Created on 11 Mar 2019

@author: <NAME> (<EMAIL>)

https://stats.idre.ucla.edu/spss/faq/coding-systems-for-categorical-variables-in-regression-analysis-2/
"""

from scs_core.data.regression import Regression


# --------------------------------------------------------------------------------------------------------------------

class CatagoricalRegression(Regression):
    """
    classdocs
    """

    # ----------------------------------------------------------------------------------------------------------------

    def __init__(self):
        """
        Constructor
        """
        self.__categories = set()


    def __len__(self):
        return len(self.__categories)


    # ----------------------------------------------------------------------------------------------------------------

    def has_midpoint(self):
        return len(self) > 0


    def has_regression(self):
        return len(self) > 0


    def append(self, _, value):
        self.__categories.add(value)


    def reset(self):
        self.__categories = set()


    # ----------------------------------------------------------------------------------------------------------------

    def midpoint(self, _=None):
        if len(self) != 1:
            return None, None

        return None, next(iter(self.__categories))


    # ----------------------------------------------------------------------------------------------------------------

    def min(self, _=None):
        ordered = sorted(self.__categories)

        return ordered[0]


    def max(self, _=None):
        ordered = sorted(self.__categories)

        return ordered[-1]


    # ----------------------------------------------------------------------------------------------------------------

    def __str__(self, *args, **kwargs):
        return "CatagoricalRegression:{categories:%s}" %  self.__categories
{'fraction_non_alphanumeric': 0.4432185145317546, 'fraction_numerical': 0.006189451022604951, 'mean_word_length': 0.7759197324414716, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 1, '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': '7547835', 'n_tokens_mistral': 814, 'n_tokens_neox': 729, 'n_words': 156}