How to use the pycm.pycm_compare.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_compare.py View on Github external
:param digit: precision digit (default value : 5)
    :type digit : int
    :param weight: class weights
    :type weight: dict
    :return: None
    """
    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)
    compare.classes = list(cm_dict.values())[0].classes
    compare.weight = {k: 1 for k in compare.classes}
    compare.digit = digit
    compare.best = None
    compare.best_name = None
    compare.sorted = None
    compare.scores = {k: {"overall": 0, "class": 0}.copy()
                      for k in cm_dict.keys()}
    if weight is not None:
        if not isinstance(weight, dict):
            raise pycmCompareError(COMPARE_WEIGHT_ERROR)
        if list(weight.keys()) == compare.classes and all(
                [isfloat(x) for x in weight.values()]):
            compare.weight = weight
        else:
            raise pycmCompareError(COMPARE_WEIGHT_ERROR)
github sepandhaghighi / pycm / pycm / pycm_compare.py View on Github external
:param cm_dict: cm's dictionary
    :type cm_dict : dict
    :param digit: precision digit (default value : 5)
    :type digit : int
    :param weight: class weights
    :type weight: dict
    :return: None
    """
    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)
    compare.classes = list(cm_dict.values())[0].classes
    compare.weight = {k: 1 for k in compare.classes}
    compare.digit = digit
    compare.best = None
    compare.best_name = None
    compare.sorted = None
    compare.scores = {k: {"overall": 0, "class": 0}.copy()
                      for k in cm_dict.keys()}
    if weight is not None:
        if not isinstance(weight, dict):
            raise pycmCompareError(COMPARE_WEIGHT_ERROR)
        if list(weight.keys()) == compare.classes and all(
                [isfloat(x) for x in weight.values()]):
            compare.weight = weight
github sepandhaghighi / pycm / pycm / pycm_compare.py View on Github external
:param compare: Compare
    :type compare : pycm.Compare object
    :param cm_dict: cm's dictionary
    :type cm_dict : dict
    :param digit: precision digit (default value : 5)
    :type digit : int
    :param weight: class weights
    :type weight: dict
    :return: None
    """
    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)
    compare.classes = list(cm_dict.values())[0].classes
    compare.weight = {k: 1 for k in compare.classes}
    compare.digit = digit
    compare.best = None
    compare.best_name = None
    compare.sorted = None
    compare.scores = {k: {"overall": 0, "class": 0}.copy()
                      for k in cm_dict.keys()}
    if weight is not None:
        if not isinstance(weight, dict):
            raise pycmCompareError(COMPARE_WEIGHT_ERROR)
github sepandhaghighi / pycm / pycm / pycm_compare.py View on Github external
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)
    compare.classes = list(cm_dict.values())[0].classes
    compare.weight = {k: 1 for k in compare.classes}
    compare.digit = digit
    compare.best = None
    compare.best_name = None
    compare.sorted = None
    compare.scores = {k: {"overall": 0, "class": 0}.copy()
                      for k in cm_dict.keys()}
    if weight is not None:
        if not isinstance(weight, dict):
            raise pycmCompareError(COMPARE_WEIGHT_ERROR)
        if list(weight.keys()) == compare.classes and all(
                [isfloat(x) for x in weight.values()]):
            compare.weight = weight
        else:
            raise pycmCompareError(COMPARE_WEIGHT_ERROR)
github sepandhaghighi / pycm / pycm / pycm_compare.py View on Github external
compare.classes = list(cm_dict.values())[0].classes
    compare.weight = {k: 1 for k in compare.classes}
    compare.digit = digit
    compare.best = None
    compare.best_name = None
    compare.sorted = None
    compare.scores = {k: {"overall": 0, "class": 0}.copy()
                      for k in cm_dict.keys()}
    if weight is not None:
        if not isinstance(weight, dict):
            raise pycmCompareError(COMPARE_WEIGHT_ERROR)
        if list(weight.keys()) == compare.classes and all(
                [isfloat(x) for x in weight.values()]):
            compare.weight = weight
        else:
            raise pycmCompareError(COMPARE_WEIGHT_ERROR)
github sepandhaghighi / pycm / pycm / pycm_compare.py View on Github external
def __compare_assign_handler__(compare, cm_dict, weight, digit):
    """
    Assign basic parameters to Comapre.

    :param compare: Compare
    :type compare : pycm.Compare object
    :param cm_dict: cm's dictionary
    :type cm_dict : dict
    :param digit: precision digit (default value : 5)
    :type digit : int
    :param weight: class weights
    :type weight: dict
    :return: None
    """
    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)
    compare.classes = list(cm_dict.values())[0].classes
    compare.weight = {k: 1 for k in compare.classes}
    compare.digit = digit
    compare.best = None
    compare.best_name = None
    compare.sorted = None
    compare.scores = {k: {"overall": 0, "class": 0}.copy()
                      for k in cm_dict.keys()}