Skip to content

Instantly share code, notes, and snippets.

@gvyshnya
Created November 21, 2017 06:37
Show Gist options
  • Save gvyshnya/bc69fe987fa49f34de98af67d99ee684 to your computer and use it in GitHub Desktop.
Save gvyshnya/bc69fe987fa49f34de98af67d99ee684 to your computer and use it in GitHub Desktop.
xgboost running with tree_method = 'hist'
import xgboost as xgb
import numpy as np
from sklearn.datasets import load_digits
from sklearn.cross_validation import train_test_split
rng = np.random.RandomState(1994)
digits = load_digits(2)
X = digits['data']
y = digits['target']
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)
dtrain = xgb.DMatrix(X_train, y_train)
dtest = xgb.DMatrix(X_test, y_test)
param = {'objective': 'binary:logistic',
'tree_method': 'hist',
'grow_policy': 'depthwise',
'max_depth': 3,
'eval_metric': 'auc'}
res = {}
bst = xgb.train(param, dtrain, 10, [(dtrain, 'train'), (dtest, 'test')],
evals_result = res)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment