from sklearn.linear_model import Logistic Regression # 导入逻辑回归模型 lr = Logistic Regression() lr.fit(X_train, y_train) y_pred = lr.predict(X_test) # 预测心脏病结果 lr_acc = lr.score(X_test, y_test)*100 lr_f1 = f1_score(y_test, y_pred)*100 print("逻辑回归预测准确率:{:.2f}%".format(lr_acc)) print("逻辑回归预测F1分数: {:.2f}%".format(lr_f1)) print('逻辑回归混淆矩阵:\n', confusion_matrix(y_test, y_pred))