November 2017
Beginner
286 pages
8h 13m
English
First, various steps need to be performed on our example data.
The data is first loaded into an R data frame object named magic, recoding the CLASS output variable to use classes 1 and -1 for gamma rays and background radiation respectively:
> magic <- read.csv("magic04.data", header = FALSE)
> names(magic) <- c("FLENGTH", "FWIDTH", "FSIZE", "FCONC", "FCONC1",
"FASYM", "FM3LONG", "FM3TRANS", "FALPHA", "FDIST", "CLASS")
> magic$CLASS <- as.factor(ifelse(magic$CLASS =='g', 1, -1))
Next, the data is split into two files: a training data and a test data frame using an 80-20 split:
> library(caret) > set.seed(33711209) > magic_sampling_vector <- createDataPartition(magic$CLASS, p = 0.80, list = FALSE) > magic_train <- magic[magic_sampling_vector, ...
Read now
Unlock full access