Created
June 20, 2019 15:37
-
-
Save ravishchawla/cebaf38793b0ee4aef129425737257e8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
params = {'n_estimators' : [10, 50, 100], 'max_depth' : [5, 10, 30, 80], \ | |
'max_features': [1, 3, 8, 15], 'min_samples_split': [3, 5, 10, 30, 50, 100]} | |
g_rfm = RandomForestRegressor(random_state=1024); | |
g_src = GridSearchCV(g_rfm, params, verbose=10, cv=5, scoring='r2'); | |
g_src.fit(X_train, y_train) | |
print(g_src.best_params_) | |
tuned_rf_model = RandomForestRegressor(max_depth=30, max_features=3, min_samples_split=100, n_estimators=100); | |
tuned_rf_model.fit(X_train, y_train); | |
y_preds_tuned = tuned_rf_model.predict(X_test); | |
print(r2_score(y_test, y_preds_tuned)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment