Skip to content

atrudel/cognitive-modeling-lab

Repository files navigation

Understanding Human Behavior with Cognitive Models

ENS Logo
Master’s Degree in Cognitive Science
École Normale Supérieure - PSL


Practical exercises in Python to introduce to cognitive modeling.
Dive into interactive labs that present fundamental approaches to study decision-making, combining computational modeling and behavioral analysis. Developed to complement lectures given by Dr. Valentin Wyart (Lecturer), these practical sessions, created and led by Amric Trudel (TD Instructor), provide access to advanced methodologies and direct application to data.
These labs are accessible to programming beginners, with bonus exercises available for more experienced students. The notebooks are self-explanatory and offer sufficient guidance and feedback (through unit tests) to help students progress at their own pace.

Lab author: amric.trudel [at] ens.psl.eu

Table of Contents

Get familiar with the two-armed Bandit task. Simulate behavior with a computational model and understand the role of parameters. Do the task and fit the model to your own behavior.

Download:   Exercise files 📦   |   Solution 📝

Understand how to use the Drift-diffusion model to analyze behavioral data from the Random-dot motion task. Fit descriptive equations for reaction time and accuracy as a function of motion coherence. For this, learn how to define a cost function.

Download:   Exercise files 📦   |   Solution 📝

Get familiar with model comparison and falsification in the Stimulus Detection Task. Implement the High-Threshold Theory (HTT) and Signal Detection Theory (SDT) models, and use ROC curves to compare them.

Download:   Exercise files 📦   |   Solution 📝

Explore variations of the Bandit task: stationary, reversal, and restless. Implement a Reinforcement Learning model and optimize its parameters for different task variants.

Download:   Exercise files 📦   |   Solution 📝

Understand how to compute the likelihood of a behavioral trajectory given a computational model. Explore how model parameters influence the likelihood and implement Maximum Likelihood Estimation (MLE).

Download:   Exercise files 📦   |   Solution 📝

Learn how to recover the parameters of a cognitive model from behavioral data. Implement parameter recovery analysis, visualize the results, and produce a confusion matrix.

Download:   Exercise files 📦   |   Solution 📝

Implement model recovery on several computational models for the Bandit task. Implement the complete model recovery analysis and report the results in an inversion matrix.

Download:   Exercise files 📦   |   Solution 📝

Learn about model selection on experimental data from the reversal Bandit task. Fit multiple RL models to participant data, compare them using information criteria, and apply cross-validation techniques.

Download:   Exercise files 📦   |   Solution 📝

Understand the basic principles of Bayesian inference: prior, likelihood, and posterior. Apply Bayes' rule to discrete and continuous distributions. Implement a Bayesian RL model and apply it to the bandit task.

Download:   Exercise files 📦   |   Solution 📝

Work on a sequential perception task. Implement two models, simulate behavior, and run the full pipeline: parameter recovery, model recovery, model fitting, and model selection (fixed and random effects).

Download:   Exercise files 📦   |   Solution 📝

Installation

⚠️ Try to you complete the installation before the first TD session to save time!

1-Download the files ⬇️

  • Create a folder on your computer where you will store all TD files.
  • Download the attached files environment.yml and td0_test_installation.ipynb and place them in the folder you just created.

2- Install Python and libraries 🐍

A) ADVANCED: If you already have Python installed (and you are familiar with the command-line terminal)

You will need a virtual environment with Python 3.11 and the dependencies listed environment.yml. You can create the new environment named tdenv with this command:

conda env create -f environment.yml

B) BEGINNER: If you need to install Python on your computer

I advise installing it with the Anaconda distribution.

Anaconda takes up about 4 GB on your hard drive. If you are concerned about storage on your computer, you can also download Miniconda, which is a smaller Python distribution that contains very few pre-installed packages, and doesn't come with Anaconda's user interface (Anaconda Navigator). If you prefer to avoid using command-line terminal, and especially if your computer runs on Windows, then Anaconda is a better choice for you.

Once you have installed Anaconda:

  1. Open the Anaconda Navigator application
  2. In the Environments 📦 tab (left side bar), create a new conda environment for the TDs:
    • Click on the Import button at the bottom of the Environment list
    • Select the environment.yml file that you downloaded previously
    • Name the new environment tdenv
    • Wait for the environment to be created. All the necessary libraries will be automatically installed.

3- Testing your installation 🎯

All our TDs will be done on Jupyter Notebooks. The JupyterLab app is appropriate for the work we will do. To check that you are ready for the first TD, run the td0_test_installation.ipynb notebook in JupyterLab:

  1. In the Anaconda Navigator, go back to the Home🏠 tab, install and launch the JupyterLab app. It will open in your browser.
  2. In JupyterLab, find the td0_test_installation.ipynb file where you placed it and double-click on it.
  3. The TD0 - Setup notebook will open. Just run the first code cell (with the imports) to check if the installed packages are working.

ADVANCED: To launch JupyterLab with the terminal, go back to the directory you created, activate the conda environment and launch JupyterLab:

conda activate tdenv
jupyter lab

License

This repository is licensed under the Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0) license.

You are free to use, modify, and share the material for non-commercial purposes, provided that proper attribution is given.

See the LICENSE file for details.

About

TD for Computational Computational Modeling course

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors