pymc-devs / pymc-devs/pymc

pymc.dims does not impute missing (NaN) observed data

Open
#8,317 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

dims feature request
Dominant language
Python
Stars
9.8k
Forks
2.3k
Avg merge
21h 39m
Merged PRs (30d)
5

Description

Unlike pm.Normal, a pymc.dims distribution given an observed DataArray containing NaNs builds the model but returns a non-finite logp instead of creating an imputation RV for the missing entries.

import numpy as np
import xarray as xr
import pymc as pm
import pymc.dims as pmd

Y = xr.DataArray([[1.0, 2.0], [np.nan, 3.0]], dims=("a", "b"))
with pm.Model(coords={"a": [0, 1], "b": [0, 1]}) as m:
    a = pmd.Normal("a", 0, 1, dims="a")
    pmd.Normal("obs", a, 1.0, observed=Y, dims=("a", "b"))

m.compile_logp()(m.initial_point())  # nan

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the pymc.dims Normal distribution path when an observed DataArray contains NaNs, using the provided model and pmd.Normal calls as the reproducer. Confirm that missing entries create an imputation RV and that m.compile_logp()(m.initial_point()) returns a finite value for the example.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.