from sklearn.metrics import (accuracy_score, confusion_matrix) y_hat_rfgs = rf_gs.predict(X_test) # 用随机森林算法的最佳参数进行预测 print("参数优化后随机森林预测准确率:", accuracy_score(y_test.T, y_hat_rfgs))