15.1 Machine Learning Setup
20200514 Packages used in this chapter include magrittr (Bache and Wickham 2026), and rattle (G. Williams 2026).
Packages are loaded into the currently running R session from your
local library directories on disk. Missing packages can be installed
using utils::install.packages() within R. On Ubuntu, for
example, R packages can also be installed using $ wajig install r-cran-<pkgname>.
# Load required packages from local library into the R session.
library(magrittr) # Data pipelines: %>% %<>% %T>% equals().
library(rattle) # Dataset: weather.The rattle::weatherAUS dataset is loaded into the template
variable ds and further template variables are setup as
introduced by Graham J. Williams (2017). See
Chapter 8 for details.
dsname <- "weatherAUS"
ds <- get(dsname)
nobs <- nrow(ds)
vnames <- names(ds)
ds %<>% clean_names(numerals="right")
names(vnames) <- names(ds)
vars <- names(ds)
target <- "rain_tomorrow"
vars <- c(target, vars) %>% unique() %>% rev()The variable form is used in this chapter as the formula
describing the model to be built.
## rain_tomorrow ~ .
## # A tibble: 275,410 × 24
## date location min_temp max_temp rainfall evaporation sunshine
## <date> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 2012-02-10 GoldCoast 19.9 27.5 5.8 NA NA
## 2 2025-04-28 Albany 12 20.2 0.5 NA NA
## 3 2015-05-02 WaggaWagga 9.8 23.1 0 3.8 6.3
## 4 2025-03-23 Darwin 26.7 31.6 8.2 1 2.5
## 5 2023-01-19 Richmond 18.4 19.3 18.4 NA NA
## 6 2012-10-08 Mildura 4.4 22.9 0 5.6 10.9
## 7 2021-10-15 Moree 12.4 23.5 0 NA NA
## 8 2013-12-08 Bendigo 11 31.2 0 6.2 NA
## 9 2018-06-02 PearceRAAF 8.6 20 0 NA 9.2
## 10 2011-03-31 Albany 15.9 23 0 4.4 10.7
## # ℹ 275,400 more rows
## # ℹ 17 more variables: wind_gust_dir <ord>, wind_gust_speed <dbl>,
## # wind_dir_9am <ord>, wind_dir_3pm <ord>, wind_speed_9am <dbl>,
## # wind_speed_3pm <dbl>, humidity_9am <int>, humidity_3pm <int>,
## # pressure_9am <dbl>, pressure_3pm <dbl>, cloud_9am <int>, cloud_3pm <int>,
## # temp_9am <dbl>, temp_3pm <dbl>, rain_today <fct>, risk_mm <dbl>,
## # rain_tomorrow <fct>
References
Bache, Stefan Milton, and Hadley Wickham. 2026. Magrittr: A Forward-Pipe Operator for r. https://magrittr.tidyverse.org.
Williams, Graham. 2026. Rattle: R Data Science Supporting Rattle. https://togaware.com/projects/rattle/.
Williams, Graham J. 2017. The Essentials of Data Science: Knowledge Discovery Using r. The r Series. CRC Press.
If you find this curated material useful then you can consider a donation to support it's ongoing availability and give you access to the PDF version of this book. The material has been scoped up by Generative AI without permission or any kind of recompense so do consider a donation if you can afford it. Unlike Generative AI your access to this materials is freely given. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Togaware has a 30 year tradition of making popular open source software which includes sold privacy preserving productivity apps, 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