{"id":16273231,"url":"https://github.com/mattansb/machine-learning-for-psychologists","last_synced_at":"2025-03-19T23:31:30.041Z","repository":{"id":172275870,"uuid":"649077998","full_name":"mattansb/Machine-Learning-foR-Psychologists","owner":"mattansb","description":"Lesson files used in the Machine Learning foR Psychologists","archived":false,"fork":false,"pushed_at":"2025-03-12T08:08:15.000Z","size":202,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-12T09:23:04.504Z","etag":null,"topics":["bgu-university","caret","psychologists","rstats","statistics","tau-university","teaching-materials","tidymodels"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mattansb.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-03T17:48:40.000Z","updated_at":"2024-08-11T16:48:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"714689dc-1710-4dd0-9578-2c000e5a386b","html_url":"https://github.com/mattansb/Machine-Learning-foR-Psychologists","commit_stats":{"total_commits":32,"total_committers":1,"mean_commits":32.0,"dds":0.0,"last_synced_commit":"be40f60bdf47164353472946a1aa4e8fa9a04f2d"},"previous_names":["mattansb/machine-learning-for-psychologists"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattansb%2FMachine-Learning-foR-Psychologists","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattansb%2FMachine-Learning-foR-Psychologists/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattansb%2FMachine-Learning-foR-Psychologists/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattansb%2FMachine-Learning-foR-Psychologists/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattansb","download_url":"https://codeload.github.com/mattansb/Machine-Learning-foR-Psychologists/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244031029,"owners_count":20386534,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bgu-university","caret","psychologists","rstats","statistics","tau-university","teaching-materials","tidymodels"],"created_at":"2024-10-10T18:23:19.338Z","updated_at":"2025-03-19T23:31:29.734Z","avatar_url":"https://github.com/mattansb.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n```{r setup, include=FALSE}\nlibrary(knitr)\n\nopts_chunk$set(echo = TRUE)\n```\n\n# Machine Learning foR Psychologists\n\n[![](https://img.shields.io/badge/Open%20Educational%20Resources-Compatable-brightgreen)](https://creativecommons.org/about/program-areas/education-oer/)\n[![](https://img.shields.io/badge/CC-BY--NC%204.0-lightgray)](http://creativecommons.org/licenses/by-nc/4.0/)  \n[![](https://img.shields.io/badge/Language-R-blue)](http://cran.r-project.org/)\n\n\u003csub\u003e*Last updated `r Sys.Date()`.*\u003c/sub\u003e\n\nThis 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 [`caret`](https://topepo.github.io/caret/)**. (Materials developed with Yael Bar-Shachar.)\n\nThese 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*](https://github.com/mattansb/Practical-Applications-in-R-for-Psychologists).\n\n**Notes:**  \n\n- This repo contains only materials relating to *Practical Applications in R*, and does not contain any theoretical or introductory materials.  \n- Please note that some code does not work *on purpose*, to force students to learn to debug.\n\n## Setup\n\n```{r, echo=FALSE}\nextract_pkgs \u003c- function(fl) {\n  if (length(fl) == 1) {\n    txt \u003c- read.delim(fl, header = FALSE)[[1]] |\u003e \n      paste0(collapse = \"\\n\")\n    \n    pkg_lib \u003c- stringr::str_extract_all(txt, pattern = \"(?\u003c=library\\\\().{1,}(?=\\\\))\")\n    \n    pkg_req \u003c- stringr::str_extract_all(txt, pattern = \"(?\u003c=require\\\\().{1,}(?=\\\\))\")\n    \n    pkg_name \u003c- stringr::str_extract_all(txt, pattern = \"[a-z|A-Z|0-9]{1,}(?=\\\\:\\\\:)\")\n    \n    pkgs \u003c- c(pkg_lib, pkg_req, pkg_name)\n    \n  } else if (length(fl) \u003e 1) {\n    pkgs \u003c- sapply(fl, extract_pkgs)\n  }\n  \n  \n  pkgs |\u003e\n    unlist(recursive = TRUE) |\u003e\n    unique()\n}\n\nmake_pkg_table \u003c- function(pkgs) {\n  pkgs \u003c- pkgs[sapply(pkgs, function(x) length(x) \u003e 0)]\n  \n  ps \u003c- sapply(pkgs, function(x){\n    paste0(\n      glue::glue(\"[`{x}`](https://CRAN.R-project.org/package={x})\"),\n      collapse = \", \"\n    )\n  })\n  \n  glue::glue(\"|[{folder}](/{folder})|{ps}|\\n\\n\",\n             folder = names(pkgs)) |\u003e \n    c(\"|Lesson|Packages|\\n|----|----|\\n\", i2 = _) |\u003e # header\n    paste0(collapse = \"\")\n}\n```\n\n\nYou will need:\n\n1. A fresh installation of [**`R`**](https://cran.r-project.org/) (preferably version 4.2 or above).\n2. [RStudio IDE](https://www.rstudio.com/products/rstudio/download/) (optional, but recommended).\n3. The following packages, listed by lesson:\n\n```{r, echo=FALSE, message=FALSE, warning=FALSE}\nr_list \u003c- list.files(pattern = \".(R|r)$\", recursive = TRUE, full.names = TRUE)\nr_list \u003c- r_list[!stringr::str_detect(r_list, pattern = \"(SOLUTION|logo)\")]\nr_list \u003c- r_list[stringr::str_detect(r_list, pattern = \"^./[0-9]\")]\n\nlesson_names \u003c- stringr::str_extract(r_list, pattern = \"(?\u003c=(/)).{1,}(?=(/))\")\n\nr_list \u003c- split(r_list, lesson_names)\n\npkgs \u003c- lapply(r_list, extract_pkgs)\n\nprint_pkgs \u003c- make_pkg_table(pkgs)\n```\n\n`r print_pkgs`\n\nYou can install all the packages used by running:\n\n```{r echo=FALSE, comment = \"\", warning=FALSE}\n\npkgs \u003c- pkgs |\u003e \n  unlist(recursive = TRUE) |\u003e \n  unique() |\u003e sort()\n\ncat(\"# in alphabetical order:\")\n\ncapture.output(cat(\"pkgs \u003c-\", capture.output(dput(pkgs)), fill = 80)) |\u003e\n  styler::style_text()\n\ncat(\"install.packages(pkgs, dependencies = TRUE)\")\n```\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ci\u003ePackage Versions\u003c/i\u003e\u003c/summary\u003e\nThe package versions used here:\n```{r, echo=FALSE}\npackinfo \u003c- installed.packages(fields = c(\"Package\", \"Version\"))\n\nget_src \u003c- function(pkg) {\n  pd \u003c- packageDescription(pkg)\n  if (is.null(src \u003c- pd$Repository)) {\n    if (!is.null(src \u003c- pd$GithubRepo)) {\n      src \u003c- paste0(\"Github: \",pd$GithubUsername,\"/\",src)\n    } else {\n      src \u003c- \"Dev\"\n    }\n  }\n  return(src)\n}\n\nV \u003c- packinfo[pkgs,\"Version\"]\nsrc \u003c- sapply(pkgs, get_src)\n# setNames(paste0(V, \" (\", src,\")\"), pkgs)\n\nv_info \u003c- paste0(glue::glue(\" - `{pkgs}` {V} (*{src}*)\"), collapse = \"\\n\")\n```\n\n`r v_info`\n\n\u003c/details\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattansb%2Fmachine-learning-for-psychologists","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattansb%2Fmachine-learning-for-psychologists","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattansb%2Fmachine-learning-for-psychologists/lists"}