Go to TogaWare.com Home Page. Data Science Desktop Survival Guide
by Graham Williams
Duck Duck Go



CLICK HERE TO VISIT THE UPDATED SURVIVAL GUIDE

ML Setup

20210102 Packages used in this chapter include ROCR, ggplot2, rpart, and rattle.

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 be installed using wajig install r-cran-<pkgname>.

# Load required packages from local library into the R session.

library(ROCR)         # Use prediction() for evaluation.
library(ggplot2)      # Display evaluations.
library(rattle)       # Dataset: weather.
library(rpart)        # ML: decision tree rpart().
library(scales)       # Support: commas(), percent().

The rattle::weatherAUS dataset is loaded into the template variable ds and further template variables are setup as introduced in Williams (2017). See Chapter 7 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()

It is always useful to remind ourselves of the dataset with a random sample:

ds  %>% sample_frac() %>% select(date, location, sample(3:length(vars), 5))
## # A tibble: 176,747 x 7
##    date       location   wind_dir_9am rainfall min_temp wind_speed_3pm t...
##    <date>     <chr>      <ord>           <dbl>    <dbl>          <dbl>  ...
##  1 2018-01-29 NorahHead  NNE               0.2     21.7             17  ...
##  2 2017-11-22 Dartmoor   NNE               0       14.9             11  ...
##  3 2020-02-16 Melbourne~ SW                3.4     15.2             11  ...
##  4 2015-11-03 Penrith    SW                0.2     17.7             11  ...
##  5 2019-07-26 Canberra   NNE               0       -1.8              9  ...
##  6 2010-09-26 Watsonia   NE                0        6.9             19  ...
##  7 2010-09-21 BadgerysC~ NNW               0.2      6.3             24  ...
##  8 2010-08-24 Brisbane   W                10.2     14               20  ...
....


Support further development by purchasing the PDF version of the book.
Other online resources include the GNU/Linux Desktop Survival Guide.
Books available on Amazon include Data Mining with Rattle and Essentials of Data Science.
Popular open source software includes rattle and wajig.
Hosted by Togaware, a pioneer of free and open source software since 1984.
Copyright © 2000-2020 Togaware Pty Ltd. . Creative Commons ShareAlike V4.