I try to recreate all figures from the textbook The Elements of Statistical Learning (2nd edition) by Trevor Hastie, Robert Tibshirani, and Jerome Friedman with R using mainly ggplot2 and mlr.
See https://web.stanford.edu/~hastie/ElemStatLearn/ where you can get a PDF of the book.
For some figures you can find the code in the accompanying R package ElemStatLearn, but for many examples/figures in the book it is not immediately clear (at least it is/was for me) how they were produced. I hope it becomes more accessible via the following notebooks (though you still have to read the book to know what is going on):
- Introduction
- Overview of Supervised Learning
- Linear Methods for Regression
- Boosting and Additive Trees
The notebooks depend on the following R packages:
install.packages(c("ElemStatLearn", "knitr", "ggplot2", "mlr", "directlabels", "ggforce", "gridExtra", "mvtnorm", "reshape2", "scales", "leaps"))
#library("mlr") # machine learning in R
#library("directlabels") # automatic label positioning in ggplot
#library("ggforce") # drawing circles in ggplot
#library("gridExtra") # arrange multiple plots
#library("leaps") # Regression Subset Selection
- general:
- graphics and ggplot:
- ggplot2 Reference
- R graph gallery: https://www.r-graph-gallery.com/
- Laying out multiple plots on a page
- ggplot2 - Easy Way to Mix Multiple Graphs on The Same Page
- anti-aliasing:
- colors:
- color names in R: http://www.stat.columbia.edu/~tzheng/files/Rcolor.pdf
- colors in ggplot2: http://www.cookbook-r.com/Graphs/Colors_(ggplot2)/
- annotations and labels: