Skip to content

Latest commit

 

History

History
126 lines (98 loc) · 5.03 KB

File metadata and controls

126 lines (98 loc) · 5.03 KB

Machine Learning foR Psychologists

Last updated 2026-04-17.

This Github repo contains all lesson files for Machine Learning in R. The goal is to impart students with the basic tools to construct, evaluate and compare various machine learning models, using tidymodels, based on An Introduction to Statistical Learning: with applications in R.

These topics were taught in the graduate-level course Machine Learning for Psychologists (Psych Dep., Ben-Gurion University of the Negev; Psych Dep., Tel-Aviv University). This course assumes basic competence in R (importing, regression modeling, plotting, etc.), along the lines of Practical Applications in R for Psychologists.

Notes:

  • This repo contains only materials relating to Practical Applications in R, and does not contain any theoretical or introductory materials.
  • Please note that some code does not work on purpose, to force students to learn to debug.

Setup

You will need:

  1. A fresh installation of R (preferably version 4.5.0 or above).
  2. RStudio IDE or Positron (optional, but recommended).
  3. The following packages, listed by lesson:
Lesson Packages
01 intro with regression ISLR, tidymodels, stats, patchwork, kknn
02 cross validation tidymodels, kknn, finetune, ISLR, mirai, glue, modeldata, patchwork, datasets, tune, performance
03 classification tidymodels, ISLR, stats, parameters, kknn, mirai, themis, patchwork, tailor, modeldata, probably, desirability2
04 the problem of over-dimensionality tidymodels, leaps, ISLR, stats, MASS, insight, glmnet, mirai, tidyr, scales, tibble, ggplot2, vip, modeldata, kknn, BiocManager, mixOmics, parsnip
05 svm tidymodels, kernlab, mirai, ISLR, ISLR2
06 trees tidymodels, rpart, rpart.plot, mirai, ISLR, scales, vip, MASS, baguette, ranger, xgboost, forcats, randomForest
07 explanatory model analysis tidymodels, kknn, ranger, patchwork, DALEX, DALEXtra, marginaleffects, ISLR, datawizard, vip, randomForest
08 clustering tidymodels, patchwork, cluster, Rtsne, factoextra, ggrepel, randomForest, fpc, pak, clusterpval, modeldata

Installing R Packages

You can install all the R packages used by running:

# in alphabetical order:

pak::pak(
  c(

    "cran::BiocManager", # 1.30.27
    "cran::DALEX", # 2.5.3
    "cran::DALEXtra", # 2.3.1
    "cran::ISLR", # 1.4
    "cran::ISLR2", # 1.3-2
    "cran::MASS", # 7.3-65
    "cran::Rtsne", # 0.17
    "cran::baguette", # 1.1.0
    "cran::cluster", # 2.1.8.2
    "github::lucylgao/clusterpval", # 1.0.1
    "cran::desirability2", # 0.2.0
    "cran::easystats", # 0.7.5
    "cran::factoextra", # 2.0.0
    "cran::finetune", # 1.2.1
    "cran::fpc", # 2.2-14
    "cran::ggrepel", # 0.9.7
    "cran::glmnet", # 4.1-10
    "cran::glue", # 1.8.0
    "cran::kernlab", # 0.9-33
    "cran::kknn", # 1.4.1
    "cran::leaps", # 3.2
    "cran::marginaleffects", # 0.32.0
    "cran::mirai", # 2.6.1
    "mixOmics", # 6.34.0
    "cran::pak", # 0.9.2
    "cran::patchwork", # 1.3.2
    "cran::probably", # 1.2.0
    "cran::randomForest", # 4.7-1.2
    "cran::ranger", # 0.18.0
    "cran::rpart", # 4.1.24
    "cran::rpart.plot", # 3.1.4
    "cran::scales", # 1.4.0
    "cran::themis", # 1.0.3
    "cran::tidymodels", # 1.4.1
    "cran::tidyverse", # 2.0.0
    "cran::vip", # 0.4.5
    "cran::xgboost" # 3.2.0.1

  )
)

Additional Versions

  • Prior to 2025, this course was based on the {caret} package - this version can still be found here.

  • Partial parallel python lessons can be found in the py folder.


Acknowledgements

Materials developed with Yael Bar-Shachar.