20.62 Party Tree

The (Hothorn et al. 2024) package can be used to draw decision trees using partykit::as.party() from (Hothorn and Zeileis 2024) 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=132754, err=14.0%)
## |   [3] humidity_3pm >= 71.5
## |   |   [4] humidity_3pm < 82.5
## |   |   |   [5] rainfall < 0.85: No (n=7884, err=34.9%)
## |   |   |   [6] rainfall >= 0.85: Yes (n=6351, err=40.6%)
....

References

Hothorn, Torsten, Kurt Hornik, Carolin Strobl, and Achim Zeileis. 2024. Party: A Laboratory for Recursive Partytioning. http://party.R-forge.R-project.org.
Hothorn, Torsten, and Achim Zeileis. 2024. Partykit: A Toolkit for Recursive Partytioning. http://partykit.r-forge.r-project.org/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