Update Python demos with tests. (#5651)
* Remove GPU memory usage demo. * Add tests for demos. * Remove `silent`. * Remove shebang as it's not portable.
This commit is contained in:
8
demo/guide-python/sklearn_examples.py
Executable file → Normal file
8
demo/guide-python/sklearn_examples.py
Executable file → Normal file
@@ -1,4 +1,3 @@
|
||||
#!/usr/bin/python
|
||||
'''
|
||||
Created on 1 Apr 2015
|
||||
|
||||
@@ -52,9 +51,9 @@ 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)
|
||||
{'max_depth': [2, 4, 6],
|
||||
'n_estimators': [50, 100, 200]}, verbose=1)
|
||||
clf.fit(X, y)
|
||||
print(clf.best_score_)
|
||||
print(clf.best_params_)
|
||||
|
||||
@@ -73,4 +72,3 @@ X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)
|
||||
clf = xgb.XGBClassifier()
|
||||
clf.fit(X_train, y_train, early_stopping_rounds=10, eval_metric="auc",
|
||||
eval_set=[(X_test, y_test)])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user