Guest User

Untitled

a guest
Nov 22nd, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import xgboost as xgb
  2. import numpy as np
  3. from sklearn.datasets import load_digits
  4. from sklearn.cross_validation import train_test_split
  5.  
  6. rng = np.random.RandomState(1994)
  7.  
  8. digits = load_digits(2)
  9. X = digits['data']
  10. y = digits['target']
  11. X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)
  12. dtrain = xgb.DMatrix(X_train, y_train)
  13. dtest = xgb.DMatrix(X_test, y_test)
  14. param = {'objective': 'binary:logistic',
  15. 'tree_method': 'hist',
  16. 'grow_policy': 'depthwise',
  17. 'max_depth': 3,
  18. 'eval_metric': 'auc'}
  19. res = {}
  20. bst = xgb.train(param, dtrain, 10, [(dtrain, 'train'), (dtest, 'test')],
  21. evals_result = res)
Add Comment
Please, Sign In to add comment