TST: Added test for parameter tuning using GridSearchCV

This commit is contained in:
terrytangyuan 2015-10-04 23:16:00 -05:00
parent 956e50686e
commit 5dd23a2195

View File

@ -42,5 +42,16 @@ def test_boston_housing_regression():
labels = y[test_index]
assert mean_squared_error(preds, labels) < 9
def test_parameter_tuning():
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)
clf.fit(X,y)
assert clf.best_score_ < 0.7
assert clf.best_params_ == {'n_estimators': 100, 'max_depth': 4}