Created
January 5, 2022 16:55
-
-
Save yashprakash13/da9b2602ae7f3cdba75bfdeb2e2dc0e2 to your computer and use it in GitHub Desktop.
Revisions
-
yashprakash13 created this gist
Jan 5, 2022 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ def objective(n_trials): params = { "n_estimators": n_trials.suggest_int("n_estimators", 100, 2000, step=100), "learning_rate": n_trials.suggest_float("learning_rate", 1e-4, 0.3, log=True), "max_depth": n_trials.suggest_int("max_depth", 3, 15), "n_iter_no_change": 50, } dtrain = xgb.DMatrix(data = X_train, label = y_train) dval = xgb.DMatrix(data = X_test, label = y_val) regressor = xgb.train(params, dtrain) y_pred = regressor.predict(dval) rmse = mean_squared_error(y_val, y_pred, squared=False) return rmse