1
Gitea Actions Experiment Test / Experiment-Actions (push) Successful in 24s

This commit is contained in:
lzh
2024-11-02 21:22:34 +08:00
parent 9d6226e04b
commit 4a8a3dad9b
-12
View File
@@ -106,15 +106,3 @@ if __name__ == "__main__":
accuracy_test = accuracy_score(y_test, y_pred_test) accuracy_test = accuracy_score(y_test, y_pred_test)
print(f"Test Accuracy: {accuracy_test}") print(f"Test Accuracy: {accuracy_test}")
# 随机森林模型
param_grid = {
'n_estimators': [100, 200, 300],
'max_depth': [5, 10, 15],
'learning_rate': [0.01, 0.05, 0.1]
}
rf = RandomForestClassifier()
grid_search = GridSearchCV(estimator=rf, param_grid=param_grid, cv=5, scoring='accuracy')
grid_search.fit(X_train, y_train)
best_rf = grid_search.best_estimator_
print("Best parameters:", grid_search.best_params_)
print("Best accuracy:", grid_search.best_score_)