Created
November 30, 2019 17:23
-
-
Save gabriel19913/2df4271c8c9c3b387da468b324abd61a to your computer and use it in GitHub Desktop.
This file contains 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
error_model= xgb.XGBRegressor() | |
model_errors = np.square(np.subtract(y_pred, y_test.reshape(1, -1)[0])) | |
parameters = {'learning_rate': [0.0001, 0.001, 0.01, 0.1, 0.2, 0.3, 0.5, 0.9], | |
'n_estimators': [100, 200, 300, 400, 500], | |
'max_depth': [3,4,6], | |
'min_child_weight': [1, 2, 3] | |
} | |
grid_xgb = RandomizedSearchCV(error_model, parameters, cv=5, n_jobs=-1) | |
grid_xgb = grid_xgb.fit(X_test, model_errors) | |
error_model = grid_xgb.best_estimator_ | |
print("O {} calibrado tem um score de {:.4f} no conjunto de teste.".format(xgb_reg.__class__.__name__, | |
xgb_reg.score(X_test, y_test))) | |
print("Estes são os melhores parâmetros: {}".format(grid_xgb.best_params_)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment