from sklearn.tree import Decision Tree Classifier # 导入决策树模型 dtc = Decision Tree Classifier() dtc.fit(X_train, y_train) dtc_acc = dtc.score(X_test, y_test)*100 y_pred = dtc.predict(X_test) # 预测心脏病结果 print("Decision Tree Test Accuracy {:.2f}%".format(dtc_acc)) print("决策树 预测准确率: {:.2f}%".format(dtc.score(X_test, y_test)*100)) print("决策树 预测F1分数: {:.2f}%".format(f1_score(y_test, y_pred)*100)) print('决策树 混淆矩阵:\n', confusion_matrix(y_pred, y_test))