workshops
workshops copied to clipboard
use different package than rpart.plot to plot decision trees
Follow up with Max on which package this is. :)
Maybe partykit?
library(rpart)
library(partykit)
tree <- rpart(Kyphosis ~ Age + Number + Start, data = kyphosis)
as.party.rpart(tree) |> plot()
Yes, partykit was the one!
Oh, this might be worth looking into: https://jkunst.com/blog/posts/2023-07-10-my-favorite-ggplot2-packages-with-examples/#ggparty
Nice! This makes me think that we could consider switching the engine from rpart to partykit, i.e. make a ctree instead of a default decision tree. (Because if it requires a conversion to a party object first, we are no further than before.)
Yeah, just came across that same hitch. I think my leaning here is to close this issue and keep the content as-is, as the partykit engine requires bonsai and it'd be nice to not have to broach the topic of parsnip extension packages in the intro workshop. We do already have folks install that package for the advanced workshop, though, and that change would also mean no need to install/load rpart.plot, so not too much overhead.🤔
Ah, another option: https://github.com/grantmcdermott/parttree. Related to #199.
For the survival-flavoured workshop at useR, I did manage to use partykit to plot the tree. Not sure if that's due to how that one is fit, or if things changed but given that it's a year later and the plot is really nice I'd say it's worth it to check in on this again.
Nope, just hit the same issue as in #208 😞 We could use it when we introduce decision trees in general (because there we fit the spec directly, not via a workflow) but that would mean we have a different plot style to the "understand your model" section.