GLAMbox is a Python toolbox for investigating the association between gaze allocation and decision behaviour, and applying the Gaze-weighted Linear Accumulator Model (Thomas, Molter et al., 2019, full text available online).
See the GLAMbox paper for detailed background, model description and example applications.
GLAMbox is written for Python 3.7 and requires a working Python environment running on your computer. We recommend to install the Anaconda Distribution (available for all major platforms). With the Python environment fully set up, the GLAMbox module can be installed from the command line using pip:
pip install glambox
This command also installs all of GLAMbox’s dependencies, which are listed in the
requirements.txt file in the Github repository.
conda you can install
glambox into a new environment, separate from your base environment:
- Create a new environment named glambox:
conda create -n glambox python=3.7
- Activate it:
conda activate glambox
- Install the
glamboxmodule and its dependencies:
pip install glambox
Fitting the GLAM to a dataset can be done in just a few lines of code:
import glambox as gb import pandas as pd # load dataset (format must be GLAMbox compatible, of course) data = pd.read_csv('data.csv') # create the GLAM model object model = gb.GLAM(data) # build the PyMC3 model model.make_model(kind='individual') # perform MCMC sampling model.fit() # inspect parameter estimates print(model.estimates) # predict data using MAP estimates, save predictions model.predict() model.prediction.to_csv('prediction.csv')
This documentation includes the three usage examples outlined in the GLAMbox paper with full code. The original Jupyter notebook files for these examples can be found in the
examples folder in the Github repository. When downloaded and run with Jupyter (also included in the Anaconda Python distribution), the notebooks can be ran interactively.
In this example, we demonstrate individual model fitting, model comparisons between model variants, and out-of-sample prediction.
In the second example, we demonstrate how to setup a hierarchical model with multiple groups, and compare parameter estimates between groups.
In the last example, we demonstrate how to perform a basic parameter recovery analyis for a given dataset, using GLAMbox.
- Example 1: Individual gaze biases
- Example 2: Hierarchical parameter estimation in cases with limited data
- Example 3: Parameter Recovery