How to use the pycm.pycm_obj.pycmCompareError function in pycm

To help you get started, we’ve selected a few pycm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sepandhaghighi / pycm / pycm / pycm_obj.py View on Github external
def __init__(self, cm_dict, by_class=False, weight=None, digit=5):
        """
        :param cm_dict: cm's dictionary
        :type cm_dict : dict
        :param by_class: compare by class flag
        :type by_class: bool
        :param weight: class weights
        :type weight: dict
        :param digit: precision digit (default value : 5)
        :type digit : int
        """
        if not isinstance(cm_dict, dict):
            raise pycmCompareError(COMPARE_FORMAT_ERROR)
        if not all(isinstance(item, ConfusionMatrix)
                   for item in cm_dict.values()):
            raise pycmCompareError(COMPARE_TYPE_ERROR)
        if not list_check_equal([getattr(item, "POP")
                                 for item in cm_dict.values()]):
            raise pycmCompareError(COMPARE_DOMAIN_ERROR)
        if len(cm_dict) < 2:
            raise pycmCompareError(COMPARE_NUMBER_ERROR)
        self.classes = list(cm_dict.values())[0].classes
        self.weight = {k: 1 for k in self.classes}
        self.digit = digit
        self.best = None
        self.best_name = None
        self.scores = {k: {"overall": 0, "class": 0}.copy()
                       for k in cm_dict.keys()}
        if by_class and weight is not None:
github sepandhaghighi / pycm / pycm / pycm_obj.py View on Github external
:type by_class: bool
        :param weight: class weights
        :type weight: dict
        :param digit: precision digit (default value : 5)
        :type digit : int
        """
        if not isinstance(cm_dict, dict):
            raise pycmCompareError(COMPARE_FORMAT_ERROR)
        if not all(isinstance(item, ConfusionMatrix)
                   for item in cm_dict.values()):
            raise pycmCompareError(COMPARE_TYPE_ERROR)
        if not list_check_equal([getattr(item, "POP")
                                 for item in cm_dict.values()]):
            raise pycmCompareError(COMPARE_DOMAIN_ERROR)
        if len(cm_dict) < 2:
            raise pycmCompareError(COMPARE_NUMBER_ERROR)
        self.classes = list(cm_dict.values())[0].classes
        self.weight = {k: 1 for k in self.classes}
        self.digit = digit
        self.best = None
        self.best_name = None
        self.scores = {k: {"overall": 0, "class": 0}.copy()
                       for k in cm_dict.keys()}
        if by_class and weight is not None:
            if not isinstance(weight, dict):
                raise pycmCompareError(COMPARE_WEIGHT_ERROR)
            if list(weight.keys()) == self.classes and all(
                    [isfloat(x) for x in weight.values()]):
                self.weight = weight
            else:
                raise pycmCompareError(COMPARE_WEIGHT_ERROR)
        (max_class_name, max_class_score) = __compare_class_handler__(self, cm_dict)
github sepandhaghighi / pycm / pycm / pycm_obj.py View on Github external
def __init__(self, cm_dict, by_class=False, weight=None, digit=5):
        """
        :param cm_dict: cm's dictionary
        :type cm_dict : dict
        :param by_class: compare by class flag
        :type by_class: bool
        :param weight: class weights
        :type weight: dict
        :param digit: precision digit (default value : 5)
        :type digit : int
        """
        if not isinstance(cm_dict, dict):
            raise pycmCompareError(COMPARE_FORMAT_ERROR)
        if not all(isinstance(item, ConfusionMatrix)
                   for item in cm_dict.values()):
            raise pycmCompareError(COMPARE_TYPE_ERROR)
        if not list_check_equal([getattr(item, "POP")
                                 for item in cm_dict.values()]):
            raise pycmCompareError(COMPARE_DOMAIN_ERROR)
        if len(cm_dict) < 2:
            raise pycmCompareError(COMPARE_NUMBER_ERROR)
        self.classes = list(cm_dict.values())[0].classes
        self.weight = {k: 1 for k in self.classes}
        self.digit = digit
        self.best = None
        self.best_name = None
        self.scores = {k: {"overall": 0, "class": 0}.copy()
                       for k in cm_dict.keys()}
        if by_class and weight is not None:
            if not isinstance(weight, dict):
                raise pycmCompareError(COMPARE_WEIGHT_ERROR)
            if list(weight.keys()) == self.classes and all(
github sepandhaghighi / pycm / pycm / pycm_obj.py View on Github external
raise pycmCompareError(COMPARE_TYPE_ERROR)
        if not list_check_equal([getattr(item, "POP")
                                 for item in cm_dict.values()]):
            raise pycmCompareError(COMPARE_DOMAIN_ERROR)
        if len(cm_dict) < 2:
            raise pycmCompareError(COMPARE_NUMBER_ERROR)
        self.classes = list(cm_dict.values())[0].classes
        self.weight = {k: 1 for k in self.classes}
        self.digit = digit
        self.best = None
        self.best_name = None
        self.scores = {k: {"overall": 0, "class": 0}.copy()
                       for k in cm_dict.keys()}
        if by_class and weight is not None:
            if not isinstance(weight, dict):
                raise pycmCompareError(COMPARE_WEIGHT_ERROR)
            if list(weight.keys()) == self.classes and all(
                    [isfloat(x) for x in weight.values()]):
                self.weight = weight
            else:
                raise pycmCompareError(COMPARE_WEIGHT_ERROR)
        (max_class_name, max_class_score) = __compare_class_handler__(self, cm_dict)
        (max_overall_name, max_overall_score) = __compare_overall_handler__(self, cm_dict)
        self.sorted = sorted(
            self.scores,
            key=lambda x: (
                self.scores[x]['class'],
                self.scores[x]['overall'],self.scores.keys()))
        self.sorted.reverse()
        scores_list = list(self.scores.values())
        if scores_list.count(self.scores[max_class_name]) == 1:
            if by_class and (weight is not None):
github sepandhaghighi / pycm / pycm / pycm_obj.py View on Github external
:type cm_dict : dict
        :param by_class: compare by class flag
        :type by_class: bool
        :param weight: class weights
        :type weight: dict
        :param digit: precision digit (default value : 5)
        :type digit : int
        """
        if not isinstance(cm_dict, dict):
            raise pycmCompareError(COMPARE_FORMAT_ERROR)
        if not all(isinstance(item, ConfusionMatrix)
                   for item in cm_dict.values()):
            raise pycmCompareError(COMPARE_TYPE_ERROR)
        if not list_check_equal([getattr(item, "POP")
                                 for item in cm_dict.values()]):
            raise pycmCompareError(COMPARE_DOMAIN_ERROR)
        if len(cm_dict) < 2:
            raise pycmCompareError(COMPARE_NUMBER_ERROR)
        self.classes = list(cm_dict.values())[0].classes
        self.weight = {k: 1 for k in self.classes}
        self.digit = digit
        self.best = None
        self.best_name = None
        self.scores = {k: {"overall": 0, "class": 0}.copy()
                       for k in cm_dict.keys()}
        if by_class and weight is not None:
            if not isinstance(weight, dict):
                raise pycmCompareError(COMPARE_WEIGHT_ERROR)
            if list(weight.keys()) == self.classes and all(
                    [isfloat(x) for x in weight.values()]):
                self.weight = weight
            else: