Tutorial: Ridge and Lasso

There are two ways of running this tutorial:

  1. On your own computer (preferred).

  2. Experimentally, on the cloud at https://madinak.shinyapps.io/tutorial_ridge_lasso/ , available for a limited time, until Friday evening March 12.

I strongly recommend the first option, meaning that you download the tutorial from https://github.com/madina-k/DSE2021_tutorials/tree/main/tutorial_ridge_lasso and run a local version of the tutorial on your own computer.

There are several reasons why running this tutorial locally is preferred:

  1. Your progress with the tutorial will be saved locally on your own computer, so you can be sure that you can see your solutions and continue the work whenever you want. The online version also caches the progress but within your browser, so as long as you work from the same browser, it might still be ok.

  2. Learning to run code on your own machine is an important skill for a data scientist :D

  3. I am experimenting with running these tutorials on the cloud for the first time. I don’t know how well the server will handle simultaneous use by different people. I expect it should be ok, but cannot guarantee it.

  4. For this reason, the tutorial on the cloud will be available online only until Friday evening, each week. During the weekend, a new tutorial will be posted online and the previous tutorial will no longer be available. Again, all your local progress will be lost.

How to run an interactive tutorial locally from your computer

Step 0. Install R and R Studio Desktop on your laptop.

If you already have those installed, perhaps you still want to update your R and R Studio to the latest available version.

Step 1. Download this folder: https://github.com/madina-k/DSE2021_tutorials/tree/main/tutorial_ridge_lasso

Step 2. Open R Studio and install the following packages for this week’s tutorial:

install.packages(c("tidyverse", "learnr", "ISLR", "naniar", "glmnet"))

Step 3. Open the tutorial’s Rmd file tutorial_ridge_lasso.Rmd in R Studio and click the green button “Run Document” at the top

Rundoc

Or if you do not see the button, run the following command within R Studio:

rmarkdown::run("thefolderwhereyousavedthetutorial/tutorial_ridge_lasso.Rmd")

Step 4. Work with the compiled tutorial. The new subsections are slowly revealed to you once you hit continue button. You get the correct answers for each quiz after you submit an answer first. You can get the correct answer to any coding question, by clicking “hint” button at the top panel of the coding chunk.