Hands-on

This notebook provides hands-on sessions for the European Central Bank Machine Learning Training: “Machine learning for econometricians.”

The hands-on session use the programming language R. To run the codes you will need to download and install R and RStudio. More details on how to install R are available in the next chapter.

The schedule is the following:

Session Subject Schedule
Session 1 Gradient descent and overfitting 1 December 9.30-11.30
Session 2 Random forest and SVM 17 December 15.30-17.30
Session 3 Deep learning 21 December 14.30-16.30

Required packages

After you have successfully installed R, you will need to install a few packages.

  • Session 1:

    • Optimisation:

      Required packages: tidyverse, numDeriv, plot3D

      If these are not installed, please run the following instructions in R:

      install.packages("tidyverse", "numDeriv", "plot3D")
    • Overfitting:

      Required packages: tidyverse, readxl, kableExtra, randomForest, ISLR, glmnet

      If these are not installed, please run the following instructions in R:

      install.packages(
         c("tidyverse", "readxl", "kableExtra", 
           "randomForest", "ISLR", "glmnet")
      )
  • Session 2: Random forest and SVM: 17 December 15.30-17.30

    • Trees and Ensemble Methods:

      Required packages: tidyverse, lubridate, arsenal, cowplot, corrplot, rpart, rpart.plot, ggtext, foreach

      If these are not installed, please run the following instructions in R:

      install.packages(c("tidyverse", "lubridate", "arsenal", "cowplot",
         "corrplot", "rpart", "rpart.plot", "ggtext", "foreach",
         "ipred", "lattice", "caret", "randomForest"))
    • Support Vector Machines:

      Required packages: tidyverse, e1071

      If these are not installed, please run the following instructions in R:

      install.packages(c("tidyverse", "e1071"))
  • Session 3: Deep learning: 21 December 14.30-16.30

    • Single notebook:

      Required packages: tidyverse, fastDummies, reshape2, keras

      install.packages("tidyverse")
      install.packages("fastDummies")
      install.packages("reshape2")

      To install Keras: please run the following instructions in R:

      install.packages("tensorflow")
      install.packages("keras")
      library(keras)
      tensorflow::install_tensorflow()
      tensorflow::tf_config()
      install_keras()

      On one of my machines, I had to install Miniconda:

      unlink(reticulate::miniconda_path(), recursive = TRUE)
      reticulate::install_miniconda(path = reticulate::miniconda_path(), 
                            update = TRUE, force = FALSE)
      keras::install_keras()