ndphillips / FFTrees

An R package to create and visualise fast-and-frugal decision trees (FFTs)
https://journal.sjdm.org/17/17217/jdm17217.pdf
135 stars 23 forks source link

Allow a 'vertical' tree style when plotting trees? #222

Open ndphillips opened 1 month ago

ndphillips commented 1 month ago

It has occurred to me that the way FFTs are visualized both in this package as well as in publications is in what I call a 'wide' orientation. In an 'width' orientation, nodes of the tree are arranged horizontally based on the exit structure of the preceding node. That is, a node below a 'left-exit' node will be placed to the right of the node above it, while a node below a 'right-exit' node will be placed to the left of the node above it.

By contrast, consider what I would call a 'vertical' orientation, where nodes are always shown vertically stacked on top of each other, regardless of the node exit.

See my crude drawing (not to scale!) below

image

(I'm pretty sure I've seen both of these versions in publications but I don't have any examples handy)

I can think of a few benefits to showing trees using this vertical orientation within FFTrees():

  1. Vertical orientations are simpler to create than wide, reducing code. There's a bunch of code in https://github.com/ndphillips/FFTrees/blob/master/R/plotFFTrees_function.R that figures out where elements should be placed based on the location of the prior node). If we used a vertical orientation, we could remove all of that logic.
  2. Vertical orientations will lead to more consistent and predictable visualization dimensions. If I was embedding plots of FFTrees in a dashboard or paper, I'd appreciate this!
  3. Vertical orientations emphasize the simplicity of ffts. That is, unlike information in 'standard' trees, information in ffts flows in one direction only -- vertically.

@hneth curious what you think about this.

hneth commented 1 month ago

Yes, I've also considered alternative tree layouts and also seen vertical designs in various publications. And I agree that a vertical arrangement of nodes has its advantages (e.g., the layout gets simpler and less dependent on exit structures). Aesthetically, vertical designs seem cleaner, but less recognizable than our current design.

Perhaps an idea for an even simpler tree layout would be to allow for placing exits horizontally next to the cue nodes (as shown in the sketch below). If we were willing to relax the strict "noise = left" and "signal = right" convention, we could also create even narrower designs by arranging all exits on one side of the nodes (see 2nd sketch below).

FFT_layout

But all these and potential future layouts could easily be created if we had a modular and well-designed plot_FFT() function. Given the importance of a good FFT visualization function for package users, that's clearly a worthwhile task to address.