Data Science Desktop Survival Guide by Graham Williams Desktop Survival Project Home Preface Data Science Introducing R R Constructs R Tasks R Strings R Read, Write, and Create Data Template Data Exploration Data Wrangling Data Visualisation Statistics ML Template ML Scenarios ML Activities ML Applications ML Algorithms Cluster Analysis Decision Trees Computer Vision Graph Data Privacy Literate Data Science Coding with Style Resources Bibliography Index

Conditional Regression Tree

We can also build a regression tree using party.

 model <- ctree(formula=form, data=ds[tr, vars])

model
 ```## ## Model formula: ## risk_mm ~ 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] rainfall <= 24 ## | | [3] humidity_3pm <= 81 ## | | | [4] humidity_3pm <= 66 ## | | | | [5] wind_gust_speed <= 52 ## | | | | | [6] humidity_3pm <= 50 ## | | | | | | [7] sunshine <= 7.5 ## | | | | | | | [8] pressure_3pm <= 1014.5 ## | | | | | | | | [9] wind_dir_9am <= NE ## | | | | | | | | | [10] humidity_3pm <= 33: 1.722 (n=... ## | | | | | | | | | [11] humidity_3pm > 33 ## | | | | | | | | | | [12] cloud_3pm <= 4 ## | | | | | | | | | | | [13] sunshine <= 5.7: 3.450 ... ## | | | | | | | | | | | [14] sunshine > 5.7: 0.331 (... ## | | | | | | | | | | [15] cloud_3pm > 4: 4.595 (n=3... ## | | | | | | | | [16] wind_dir_9am > NE ## | | | | | | | | | [17] pressure_3pm <= 1005.1: 3.847 (... ## | | | | | | | | | [18] pressure_3pm > 1005.1: 1.345 (n... ## | | | | | | | [19] pressure_3pm > 1014.5 ## | | | | | | | | [20] pressure_3pm <= 1023.5 ## | | | | | | | | | [21] cloud_3pm <= 5: 0.423 (n=855,... ## | | | | | | | | | [22] cloud_3pm > 5: 0.826 (n=1029,... ## | | | | | | | | [23] pressure_3pm > 1023.5 ## | | | | | | | | | [24] rainfall <= 9: 0.099 (n=506, ... ## | | | | | | | | | [25] rainfall > 9: 1.000 (n=12, er... ## | | | | | | [26] sunshine > 7.5 ## | | | | | | | [27] pressure_3pm <= 1008.5 ## | | | | | | | | [28] humidity_3pm <= 31 ## | | | | | | | | | [29] humidity_3pm <= 23 ## | | | | | | | | | | [30] humidity_3pm <= 13: 0.046 (... ## | | | | | | | | | | [31] humidity_3pm > 13: 0.257 (n... ## | | | | | | | | | [32] humidity_3pm > 23: 0.705 (n=7... ## | | | | | | | | [33] humidity_3pm > 31 ## | | | | | | | | | [34] cloud_3pm <= 3 ## | | | | | | | | | | [35] sunshine <= 9.9: 1.001 (n =... ## | | | | | | | | | | [36] sunshine > 9.9: 0.250 (n=... .... ```