Random Forest

Handout

Exercises

## Your current working directoy
getwd()
## Go to the MDA directory
setwd("MDA")
## Create a new directory and go there 
dir.create("RandomForests"); setwd("RandomForests")

Exercise Iris

The Iris dataset is a small dataset with little meaning to microbiota data. But its simplicity makes it a good dataset to play and learn more about modeling with random forests.

## Download the R script for the exercises
rf1.url <- "https://www.gdc-docs.ethz.ch/MDA/scripts/RandomForest_GetStarted_Iris_V190717.R"
utils::download.file(rf1.url, destfile = "RF_Iris.R")
file.edit("RF_Iris.R")

Exercise Food

## Download the R script for the exercises
rf2.url <- "https://www.gdc-docs.ethz.ch/MDA/scripts/RandomForest_Food_V200128.R"
utils::download.file(rf2.url, destfile = "RF_Food.R")
file.edit("RF_Food.R")

Just in case you "lost" the food data set. Here it is again.

# Food data
food.url <- "https://www.gdc-docs.ethz.ch/MDA/data/food.Rdata"
utils::download.file(food.url, destfile = "food.Rdata")
load("food.Rdata")