generated from LufsX/Experiment-LogReg
This commit is contained in:
-12
@@ -106,15 +106,3 @@ if __name__ == "__main__":
|
||||
accuracy_test = accuracy_score(y_test, y_pred_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_)
|
||||
Reference in New Issue
Block a user