3

xgb.train is the low level API to train an xgboost model in Python.

  • When I use XGBClassifier, which is a wrapper and calls xgb.train when a model is trained, I can print the XGBClassifier object and the hyperparameters are printed.
  • When using xgb.train I have no idea how to check the parameters after training

Code:

bst = xgb.train(params, dtrain)
bst.params # does not work!
Jakub Szlaur
  • 1,852
  • 10
  • 39
gato
  • 91
  • 1
  • 9

1 Answers1

2

The save_config method noted here can be used to create a string representation of the model's configuration. This can be converted to a dict:

import json

config = json.loads(bst.save_config())

The result is somewhat deeply nested, but the hyperparameters are found like this:

config['learner']['gradient_booster']['updater']['grow_colmaker']['train_param']

sply88
  • 643
  • 3
  • 7