parrt / dtreeviz

A python library for decision tree visualization and model interpretation.
MIT License
2.94k stars 331 forks source link

Visualize custom decision tree #301

Open erdiphd opened 1 year ago

erdiphd commented 1 year ago

Hello I would like to visualize my custom decisition tree without using the optimized decision tree from the sklearn library

clf = DecisionTreeClassifier(max_depth=4)
clf.fit(X, y)

For example; I have the following Decision Tree and would like to visualize it using the dtreeviz library. How can I do it ? Thanks

if _in_1 < 9.0:
    if _in_0 > 11.0:
        if _in_1 < 8.0:
            out=2

        else:
            out=0

    else:
        if _in_0 < 13.0:
            if _in_0 > 7.0:
                out=1

            else:
                out=0

        else:
            out=0

else:
    out=0
tlapusan commented 1 year ago

hi @erdiphd, if you look inside the details implementation of the dtreeviz, you will see that each supported library has a custom implementation of the shadow_decision_tree.ShadowDecTree().

If you want to display your own library, you should add a new implementation for ShadowDecTree.

Or maybe a simpler version would be to use Graphviz. You could check more for it and to see if it's a better fit.