Skip to content

Add HMM missing-observation support and an HMM missingness tutorial#252

Open
mattlevine22 wants to merge 17 commits into
mainfrom
ml-missingness-hmm-2
Open

Add HMM missing-observation support and an HMM missingness tutorial#252
mattlevine22 wants to merge 17 commits into
mainfrom
ml-missingness-hmm-2

Conversation

@mattlevine22

Copy link
Copy Markdown
Collaborator

This PR adds NaN-based missing-observation support to the exact HMM filter by reusing the shared masked observation log-probability machinery already used on the simulator side. Fully missing rows now act as neutral observation updates, and partial missingness is supported for exact-marginalizable HMM observation families such as MultivariateNormal and factorizable Independent(..., 1) observations. Internally, the prepared observation mask/safe-value views are computed once and reused across filtering and simulator paths rather than being recomputed downstream.

It also adds regression coverage for the supported and unsupported HMM missingness cases, updates the HMMConfig docs/checker behavior, and introduces a new Part 11c tutorial showing the two clean built-in HMM missingness workflows: multivariate Gaussian observations and independent categorical observations. The tutorial index is updated to link to the new notebook.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends dynestyx’s exact HMM filtering path to support NaN-based missing observations by reusing (and centralizing) the masked observation log-probability machinery already used for simulator-side conditioning. It also adds regression tests and a new tutorial entry documenting supported missingness workflows (MVN and Independent(..., 1)).

Changes:

  • Add shared missing-observation preprocessing (safe observation values + masks) and reuse it across HMM filtering and simulator conditioning paths.
  • Extend exact HMM emission scoring to treat fully-missing rows as neutral updates and marginalize partially-missing rows for supported observation families.
  • Add missingness-focused test coverage for HMMs and discrete simulator conditioning error paths; update docs/config checker behavior accordingly.

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/missingness/test_hmm.py Adds comprehensive regression tests for HMM missingness (full-row + partial) including categorical cases and traced MCMC paths.
tests/missingness/test_discrete_simulator.py Adds simulator missingness/MCMC smoke coverage and a clearer error for categorical conditioning under DiscreteTimeSimulator.
dynestyx/simulators.py Threads precomputed observation views through simulator paths; adds categorical-conditioning rejection and improved missingness handling for Dirac observations.
dynestyx/ops.py Introduces a new ops module with a second _sample_intp/HandlesSelf definition (currently duplicative vs handlers.py).
dynestyx/observation_missingness.py Refactors missingness logic into reusable helpers (prepare_observation_mask, masked_observation_log_prob, distribution contract probing).
dynestyx/inference/hmm_filters.py Updates HMM emission scoring to use masked log-prob and reuse precomputed safe obs/masks.
dynestyx/inference/filters.py Plumbs preprocessed observation views through batched filter dispatch; records HMM filtered/log-filtered states for plated cases.
dynestyx/inference/filter_configs.py Updates HMMConfig docs to describe supported NaN-based missingness (including categorical encoding).
dynestyx/inference/checkers.py Removes prior blanket prohibition on NaNs for HMM filtering.
dynestyx/handlers.py Adds _prepare_observation_views to precompute safe observations/masks once and pass them to handlers.
docs/tutorials/gentle_intro/00_index.ipynb Adds a link to the new “Part 11c” HMM missingness tutorial.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread dynestyx/handlers.py
Comment thread dynestyx/ops.py Outdated
@mattlevine22 mattlevine22 removed the request for review from DanWaxman June 11, 2026 17:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.

Comment thread dynestyx/observation_missingness.py
Comment thread dynestyx/observation_missingness.py
Comment thread dynestyx/observation_missingness.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants