(data_inst)
check label. FTL only supports binary classification, and labels should be 1 or -1
check label. FTL only supports binary classification, and labels should be 1 or -1
check label . FTL only supports binary classification and labels should be 1 or - 1
def check_label(data_inst):

        """
        check label. FTL only supports binary classification, and labels should be 1 or -1
        """

        LOGGER.debug('checking label')
        label_checker = ClassifyLabelChecker()
        num_class, class_set = label_checker.validate_label(data_inst)
        if num_class != 2:
            raise ValueError('ftl only support binary classification, however {} labels are provided.'.format(num_class))

        if 1 in class_set and -1 in class_set:
            return data_inst
        else:
            soreted_class_set = sorted(list(class_set))
            new_label_mapping = {soreted_class_set[1]: 1, soreted_class_set[0]: -1}
            reset_label = functools.partial(FTL.reset_label, mapping=new_label_mapping)
            new_table = data_inst.mapValues(reset_label)
            new_table.schema = copy.deepcopy(data_inst.schema)
            return new_table
def check_label ( data_inst ) : LOGGER . debug ( 'checking label' ) label_checker = ClassifyLabelChecker ( ) num_class , class_set = label_checker . validate_label ( data_inst ) if num_class != 2 : raise ValueError ( 'ftl only support binary classification, however {} labels are provided.' . format ( num_class ) ) if 1 in class_set and - 1 in class_set : return data_inst else : soreted_class_set = sorted ( list ( class_set ) ) new_label_mapping = { soreted_class_set [ 1 ] : 1 , soreted_class_set [ 0 ] : - 1 } reset_label = functools . partial ( FTL . reset_label , mapping = new_label_mapping ) new_table = data_inst . mapValues ( reset_label ) new_table . schema = copy . deepcopy ( data_inst . schema ) return new_table