GLAMbox

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.

Installation

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.

Tip

Using conda you can install glambox into a new environment, separate from your base environment:

  1. Create a new environment named glambox: conda create -n glambox python=3.7
  2. Activate it: conda activate glambox
  3. Install the glambox module and its dependencies: pip install glambox

Quickstart

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')

A more detailed overview of the available functions can be found in the Basic Usage section and the API Reference.

Application Examples

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.

Example 1: Individual gaze biases

In this example, we demonstrate individual model fitting, model comparisons between model variants, and out-of-sample prediction.

Example 2: Hierarchical parameter estimation

In the second example, we demonstrate how to setup a hierarchical model with multiple groups, and compare parameter estimates between groups.

Indices and tables