xgboost/demo/guide-python/sklearn_parallel.py
Jiaming Yuan 2c1a439869
Update Python demos with tests. (#5651)
* Remove GPU memory usage demo.
* Add tests for demos.
* Remove `silent`.
* Remove shebang as it's not portable.
2020-05-12 12:04:42 +08:00

18 lines
540 B
Python

from sklearn.model_selection import GridSearchCV
from sklearn.datasets import load_boston
import xgboost as xgb
if __name__ == "__main__":
print("Parallel Parameter optimization")
boston = load_boston()
y = boston['target']
X = boston['data']
xgb_model = xgb.XGBRegressor()
clf = GridSearchCV(xgb_model, {'max_depth': [2, 4, 6],
'n_estimators': [50, 100, 200]}, verbose=1,
n_jobs=2)
clf.fit(X, y)
print(clf.best_score_)
print(clf.best_params_)