fidelity / mabwiser

[IJAIT 2021] MABWiser: Contextual Multi-Armed Bandits Library
https://fidelity.github.io/mabwiser/
Apache License 2.0
213 stars 42 forks source link

Is there a way to retrieve DecisionTree output? #73

Closed cstetter closed 1 year ago

cstetter commented 1 year ago

I have chosen a decision tree as neighborhood policy. Is there any way to get the output of the decision tree, e.g. as an image?

bkleyn commented 1 year ago

Hey @cstetter

Unfortunately, we don't have that kind of plotting functionality built-in.

However, we do use the Scikit-learn DecisionTreeRegressor implementation internally, so you might be able to access that inside the MAB object and then use plotting functionality from Scikit-learn or elsewhere.

You can access the individual decision trees for each arm using something like below:

treebandit = MAB(...)
arm_to_tree = treebandit._imp.arm_to_tree
skadio commented 1 year ago

@cstetter if you end up using the internal treebandit._imp.arm_to_tree as mentioned the above and have a plotting functionality available (with usual sklearn tree plotting), it would be cool if you share a PR with us to showcase that in the treebandit example https://github.com/fidelity/mabwiser/blob/master/examples/contextual_mab.py#L216

If you like our library, we would much appreciate a github star 🌟 to spread the word!

cstetter commented 1 year ago

@bkleyn Thanks, this works perfectly! @skadio I'll try to do that ASAP.

Thank you for your help.

skadio commented 1 year ago

very cool!