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:
Jiaming Yuan
2020-05-12 12:04:42 +08:00
committed by GitHub
parent 4e64e2ef8e
commit 2c1a439869
25 changed files with 158 additions and 158 deletions

8
demo/guide-python/sklearn_examples.py Executable file → Normal file
View 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)])