20.61 Party Tree

The (Hothorn et al. 2026) package can be used to draw decision trees using partykit::as.party() from (Hothorn and Zeileis 2026) which can be installed from R-Forge:

install.packages("partykit", repos="http://R-Forge.R-project.org")
library(partykit)
class(model)
## [1] "rpart"
plot(as.party(model))

The textual presentation of an rpart decision tree can also be improved using party.

print(as.party(model))
## 
## Model formula:
## rain_tomorrow ~ rain_today + temp_3pm + temp_9am + cloud_3pm + 
##     cloud_9am + pressure_3pm + pressure_9am + humidity_3pm + 
##     humidity_9am + wind_speed_3pm + wind_speed_9am + wind_dir_3pm + 
##     wind_dir_9am + wind_gust_speed + wind_gust_dir + sunshine + 
##     evaporation + rainfall + max_temp + min_temp
## 
## Fitted party:
## [1] root
## |   [2] humidity_3pm < 71.5: No (n=160906, err=13.7%)
## |   [3] humidity_3pm >= 71.5
## |   |   [4] humidity_3pm < 82.5
## |   |   |   [5] wind_gust_speed < 42: No (n=10597, err=36.5%)
## |   |   |   [6] wind_gust_speed >= 42: Yes (n=6884, err=39.9%)
....

References

Hothorn, Torsten, Kurt Hornik, Carolin Strobl, and Achim Zeileis. 2026. Party: A Laboratory for Recursive Partytioning. https://codeberg.org/thothorn/party.
Hothorn, Torsten, and Achim Zeileis. 2026. Partykit: A Toolkit for Recursive Partytioning. https://codeberg.org/thothorn/partykit.


Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0