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).
See the BioRxiv preprint 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.
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 BioRxiv preprint 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