(score_list)
return binary_result
one-vs-rest transformation: multi classification result to several binary classification results
one-vs-rest transformation: multi classification result to several binary classification results
one - vs - rest transformation : multi classification result to several binary classification results
def _unfold_multi_result(score_list):
        """
        one-vs-rest transformation: multi classification result to several binary classification results
        """

        binary_result = {}
        for key, multi_result in score_list:
            true_label = multi_result[0]
            predicted_label = multi_result[1]
            multi_score = multi_result[3]
            data_type = multi_result[-1]
            # to binary predict result format
            for multi_label in multi_score:
                bin_label = 1 if str(multi_label) == str(true_label) else 0
                bin_predicted_label = 1 if str(multi_label) == str(predicted_label) else 0
                bin_score = multi_score[multi_label]
                neg_bin_score = 1 - bin_score
                result_list = [bin_label, bin_predicted_label, bin_score, {1: bin_score,  0: neg_bin_score}, data_type]
                if multi_label not in binary_result:
                    binary_result[multi_label] = []
                binary_result[multi_label].append((key, result_list))

        return binary_result
def _unfold_multi_result ( score_list ) : binary_result = { } for key , multi_result in score_list : true_label = multi_result [ 0 ] predicted_label = multi_result [ 1 ] multi_score = multi_result [ 3 ] data_type = multi_result [ - 1 ] # to binary predict result format for multi_label in multi_score : bin_label = 1 if str ( multi_label ) == str ( true_label ) else 0 bin_predicted_label = 1 if str ( multi_label ) == str ( predicted_label ) else 0 bin_score = multi_score [ multi_label ] neg_bin_score = 1 - bin_score result_list = [ bin_label , bin_predicted_label , bin_score , { 1 : bin_score , 0 : neg_bin_score } , data_type ] if multi_label not in binary_result : binary_result [ multi_label ] = [ ] binary_result [ multi_label ] . append ( ( key , result_list ) ) return binary_result