(y_true, y_pred)
return precision, recall, f1
numpy版 序列二分类f1
        :param y_true:
        :param y_pred:
        :return:
numpy版 序列二分类f1
        :param y_true:
        :param y_pred:
        :return:
numpy版 序列二分类f1 : param y_true : : param y_pred : : return :
def match_f1(y_true, y_pred):
    '''
        numpy版 序列二分类f1
        :param y_true:
        :param y_pred:
        :return:
        '''
    threshold_valud = 0.5
    y_true = np.reshape(y_true, (-1))
    y_pred = [1 if p >= threshold_valud else 0 for p in np.reshape(y_pred, (-1))]
    equal_num = np.sum([1 for t, p in zip(y_true, y_pred) if t == p and t == 1 and p == 1])
    true_sum = np.sum(y_true)
    pred_sum = np.sum(y_pred)
    precision = equal_num / pred_sum
    recall = equal_num / true_sum
    f1 = (2 * precision * recall) / (precision + recall)
    return precision, recall, f1
def match_f1 ( y_true , y_pred ) : threshold_valud = 0.5 y_true = np . reshape ( y_true , ( - 1 ) ) y_pred = [ 1 if p >= threshold_valud else 0 for p in np . reshape ( y_pred , ( - 1 ) ) ] equal_num = np . sum ( [ 1 for t , p in zip ( y_true , y_pred ) if t == p and t == 1 and p == 1 ] ) true_sum = np . sum ( y_true ) pred_sum = np . sum ( y_pred ) precision = equal_num / pred_sum recall = equal_num / true_sum f1 = ( 2 * precision * recall ) / ( precision + recall ) return precision , recall , f1