# Gaussianising Transformations Experiments

This repository contains the code used to run the experiments, simulations, and figure-generation steps for the paper "Effects of applying Gaussianising transformations to DNN embeddings before calculating likelihood ratios".

## Environment setup

This code was developed and tested on Python 3.9.18.

We recommend creating a dedicated conda environment before running the experiments:

```bash
conda create -n transforms python=3.9.18
conda activate transforms
```

Then install the required Python packages:

```bash
pip install -r requirements.txt
```

## Running the experiments

Run the scripts from the repository root in the following order:

```bash
python run_experiments.py
python run_simulations.py
python plot_lengths_and_angles.py
```

The intended workflow is:

1. `run_experiments.py`: runs the main experiments. Transforms the data, computes uncalibrated likelihood ratios using a two-covariance PLDA model, and calibrates using leave-one-out/leave-two-out cross-validation calibration with regularised logistic regression calibration. This should take a while to run (around 40 min. on a Intel Core i7 13th gen)  
2. `run_simulations.py`: runs the simulations presented in section 2 in the paper.
3. `plot_lengths_and_angles.py`: generates the plots for lengths and angles after the experiment and simulation outputs are available.

## Reproducing illustration figures from section 3

The notebooks whose names start with `illustrations_on_3d_synthetic_data` reproduce the figures in the paper that illustrate each transformation on 3D simulated data:

- `illustrations_on_3d_synthetic_data_GMM.ipynb`: uses a Gaussian Mixture Model to generate bi-modal synthetic data.
- `illustrations_on_3d_synthetic_data_multivariate_t.ipynb`: uses a multivariate t-distribution to generate heavy-tailed synthetic data.
