dmlc / xgboost

Scalable, Portable and Distributed Gradient Boosting (GBDT, GBRT or GBM) Library, for Python, R, Java, Scala, C++ and more. Runs on single machine, Hadoop, Spark, Dask, Flink and DataFlow
https://xgboost.readthedocs.io/en/stable/
Apache License 2.0
25.92k stars 8.69k forks source link

Does xgboost support printing decision process? #9128

Open Anarion-zuo opened 1 year ago

Anarion-zuo commented 1 year ago

Decision process should show how a certain value is computed through the decision tree, perhaps recording the branch taken at each tree node.

If no such feature exists for the time being, perhaps I could implement it in a PR later on?

Thanks

hcho3 commented 1 year ago

XGBoost does not have such feature yet. You can however inspect the tree structure by using dump_model() function.

hcho3 commented 1 year ago

perhaps I could implement it in a PR later on?

Sure, how about implementing a function like decision_path() in scikit-learn?

https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestClassifier.html#sklearn.ensemble.RandomForestClassifier.decision_path

Anarion-zuo commented 1 year ago

Great. I should start hacking.

Anarion-zuo commented 1 year ago

I have opened a PR here. https://github.com/dmlc/xgboost/pull/9151