8.4 Variables and Model Target

Reviewing the variables we will note the different roles each of the variables play. Again we make use of the template in identifying variable roles. Notice the choice to place the target variable at the end of the variable list which is common practice. Loading the dataset into rattle will then automatically identify this variable as the target variable. Reverse the list to generate a stats::formula().

# Note the available variables.

vars <- names(ds) %T>% print()
##  [1] "date"            "location"        "min_temp"        "max_temp"       
##  [5] "rainfall"        "evaporation"     "sunshine"        "wind_gust_dir"  
##  [9] "wind_gust_speed" "wind_dir_9am"    "wind_dir_3pm"    "wind_speed_9am" 
## [13] "wind_speed_3pm"  "humidity_9am"    "humidity_3pm"    "pressure_9am"   
## [17] "pressure_3pm"    "cloud_9am"       "cloud_3pm"       "temp_9am"       
## [21] "temp_3pm"        "rain_today"      "risk_mm"         "rain_tomorrow"
# Note the target variable.

target <- "rain_tomorrow"

# Place the target variable at the beginning of the vars.

vars <- c(target, vars) %>% unique() %>% rev() %T>% print()
##  [1] "risk_mm"         "rain_today"      "temp_3pm"        "temp_9am"       
##  [5] "cloud_3pm"       "cloud_9am"       "pressure_3pm"    "pressure_9am"   
##  [9] "humidity_3pm"    "humidity_9am"    "wind_speed_3pm"  "wind_speed_9am" 
## [13] "wind_dir_3pm"    "wind_dir_9am"    "wind_gust_speed" "wind_gust_dir"  
## [17] "sunshine"        "evaporation"     "rainfall"        "max_temp"       
## [21] "min_temp"        "location"        "date"            "rain_tomorrow"


Your donation will support ongoing development 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-2021 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0.