JuliaAI / DecisionTree.jl

Julia implementation of Decision Tree (CART) and Random Forest algorithms
Other
356 stars 102 forks source link

Replace `L` by `<` and `R` by `≥` #172

Closed rikhuijzer closed 2 years ago

rikhuijzer commented 2 years ago

This PR is a suggestion to make the print output of print_tree easier to understand without context.

Before (dev branch)

Feature 3, Threshold -28.166052806422238
L-> Feature 2, Threshold -161.04351901384842
    L-> 5 : 842/3650
    R-> 7 : 2493/10555
R-> Feature 7, Threshold 108.1408338577021
    L-> 2 : 2434/15287
    R-> 8 : 1227/3508

After (this PR)

Feature 3 < -28.156052806422238 ?
├─ Feature 2 < -161.04351901384842 ?
   ├─ 5 : 842/3650
   └─ 7 : 2493/10555
└─ Feature 7 < 108.1408338577021 ?
   ├─ 2 : 2434/15287
   └─ 8 : 1227/3508
ablaom commented 2 years ago

Thanks @rikhuijzer . I'm not sure you realised, but recently added was an implementation of the AbstractTrees.jl interface for decision trees and we made similar changes for that version of printing a node. See my suggestion here and the final implementation here. If we are going to change the built in print_tree, then I guess we should be consistent with that.

For more on the AbstractTrees.jl interface query the wrap doc-string and see the end of the readme.

@roland-KA Your thoughts?

roland-KA commented 2 years ago

I'm a big fan of consistency 😊 ... so I would appreciate the change suggested above by @rikhuijzer 👍. That's identical to what we did with AbstractTrees, isn't it?

ablaom commented 2 years ago

It is now. Thanks for taking on the suggestion @rikhuijzer.