TST: Added test for early stopping
This commit is contained in:
parent
412310ed04
commit
956e50686e
9
tests/python/test_early_stopping.py
Normal file
9
tests/python/test_early_stopping.py
Normal file
@ -0,0 +1,9 @@
|
||||
import xgboost as xgb
|
||||
|
||||
|
||||
X = digits['data']
|
||||
y = digits['target']
|
||||
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)])
|
||||
@ -1,9 +1,7 @@
|
||||
import pickle
|
||||
import xgboost as xgb
|
||||
|
||||
import numpy as np
|
||||
from sklearn.cross_validation import KFold, train_test_split
|
||||
from sklearn.metrics import confusion_matrix, mean_squared_error
|
||||
from sklearn.metrics import mean_squared_error
|
||||
from sklearn.grid_search import GridSearchCV
|
||||
from sklearn.datasets import load_iris, load_digits, load_boston
|
||||
|
||||
@ -45,4 +43,4 @@ def test_boston_housing_regression():
|
||||
assert mean_squared_error(preds, labels) < 9
|
||||
|
||||
|
||||
test_boston_housing_regression()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user