(model, features, target)
return f1_score(target, y_pred, pos_label=1), sum(target == y_pred) / float(len(y_pred))
使用模型进行预测
使用模型进行预测
使用模型进行预测
def predict_labels(model, features, target):
    ''' 使用模型进行预测 '''
    # 记录预测时长
    start = time()
    y_pred = model.predict(features)
    end = time()
    print("预测时间 in {:.4f} 秒".format(end - start))
    return f1_score(target, y_pred, pos_label=1), sum(target == y_pred) / float(len(y_pred))
def predict_labels ( model , features , target ) : # 记录预测时长 start = time ( ) y_pred = model . predict ( features ) end = time ( ) print ( "预测时间 in {:.4f} 秒".format(en d  - sta r t)) return f1_score ( target , y_pred , pos_label = 1 ) , sum ( target == y_pred ) / float ( len ( y_pred ) )