Week 1,2 GSOC - 2024

Rohan BabbarRohan Babbar
2 min read

This blog post marks the start of the project "Prior Elicitation (PreliZ)" with ArviZ during the first two weeks of GSoC 2024.

Work Done

  1. Adds support for multiple targets with weights to ppe

  2. Add pymc support to predictive_explorer

  3. Add support for engine="auto" and bambi models in predictive_explorer

Support for multiple targets with weights to Projective Predictive Elicitation

PPE is a predictive method available in PreliZ that returns prior samples approximating the prior distribution to induce a prior predictive distribution close to the target. I worked on increasing the number of targets, assigning weights to each target, and adding tests.

import numpy as np
import pymc as pm
import preliz as pz

Y = 2 + np.random.normal(0, 10)
target = [
    (pz.Normal(mu=174, sigma=20), 0.5),
    (pz.Normal(mu=176, sigma=19.5), 0.4),
    (pz.StudentT(mu=174, sigma=20, nu=3), 0.1),
]
with pm.Model() as model:
    x = pm.Normal("x", mu=0, sigma=10)
    z = pm.HalfNormal("z", 10)
    y = pm.Normal("y", x, z, observed=Y)
prior, new_prior, pymc_string = pz.ppe(model, target)
print(pymc_string)
with pm.Model() as model:
   x = pm.Normal("x", mu=32.5, sigma=2.34e-13)
   z = pm.HalfNormal("z", sigma=159)

Additionally, I added tests using Pytest to verify the functionality.

PyMC Support for Predictive Explorer

predictive_explorer creates text boxes and plots samples returned by a function related to PreliZ distributions, allowing interactive exploration of how prior predictive distributions change with modified priors. The function was expanded with PyMC functionality to support PyMC distributions. You can head over to Predictive Explorer and click on the PyMC tab to see an example.

Added parameter engine and extended support for Bambi models

An engine parameter was added to allow users to specify the library used to define the model: either preliz, PyMC, or Bambi. The default is set to "auto", meaning the function will automatically select the appropriate library based on the provided model.

The function was expanded with Bambi functionality to support Bambi models. Since Bambi models use PyMC on the backend, implementing it was straightforward. You can head over to Predictive Explorer and click on the Bambi tab to see the example.

To do in the coming week

Write tests in Pytest for the new Predictive Explorer feature, try out additional examples, and document everything clearly in Sphinx.

Thank you for reading my post!

0
Subscribe to my newsletter

Read articles from Rohan Babbar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Rohan Babbar
Rohan Babbar