Skip to main content

Random Forests & Neural Nets

Week 9. Everything so far has been a model you write down: a line, a curve, a GLM, a smooth. This week the model finds the shape itself. A decision tree asks one yes/no question at a time; a random forest grows hundreds of trees on resampled data and averages them; a neural network stacks many small logistic regressions. We fit all three, read what a forest learned with importance and partial dependence, and compare every model the honest way, on data it never saw. Only the Monday lecture this week (Thanksgiving).

Problem Set 9: Random Forests & Neural Networks — due Monday, November 30, 1:10 PM. Submit on Canvas.

Answer key: posted here at 3 PM on Monday, November 30.

Data: cattle_health.csv and cattle_health_new.csv (simulated: 300 cattle, % of diet that is grass, breed, healthy or sick; a second herd of 300 to test on), wheat_fields.csv and wheat_fields_new.csv (simulated: 800 wheat fields with ten predictors and yield, and 400 more to test on), and for Problem Set 9: pistachio.csv


Monday — Trees, random forests and neural networks

How a tree picks a split; a tree as a step function and why one tree is unstable; bagging, the random choice of predictors at each split (mtry) and out-of-bag error; a forest vs. logistic regression; a harder problem with ten predictors, thresholds and interactions; variable importance by shuffling and partial dependence plots; correlated predictors sharing importance; one node as a logistic regression, activation functions, hidden nodes, random starts; choosing a model by testing on new data.

No class Wednesday or Friday (Thanksgiving)

The MANOVA and transformations lecture is a self-study page this year: MANOVA & Transformations.

Key Packages

library(rpart)          # one tree
library(rpart.plot)     # draw it
library(randomForest)   # random forests, importance()
library(neuralnet)      # neural networks

Earlier versions