A Python project focused on probabilistic modeling and inference under uncertainty. This repository explores Bayesian networks and hidden-state estimation with noisy observations, emphasizing clean abstractions, reproducibility, and testability.
Many machine learning systems must reason under uncertainty using incomplete or noisy signals. This project explores foundational probabilistic inference techniques by building explicit models for:
- Causal reasoning with Bayesian networks
- Hidden variable inference
- Belief updates from noisy observations
The goal is not to build a single end-to-end agent, but to design modular inference components that can be reused, tested, and extended.
The repository contains two primary inference systems:
A Bayesian network is constructed to model causal relationships in a lab safety scenario. The network encodes dependencies between events such as training, inspections, equipment failure, and accident severity, and supports probabilistic queries using explicit conditional probability tables (CPTs).
This component focuses on:
- Probabilistic graphical models
- Causal structure representation
- Exact inference using
pgmpy
2. Hidden-State Inference with Noisy Observations
A custom TextWorld environment models a hidden ghost location that cannot be directly observed. Instead, the agent receives noisy distance measurements and partial sensor distributions. The environment is designed to support belief tracking and probabilistic state estimation.
This component focuses on:
- Hidden variables
- Noisy observations
- Inference over latent state
src/inference/ ├── bayesian_network.py # Bayesian network construction and visualization ├── ghost_tracker.py # Hidden-state inference environment ├── utils.py # Shared helpers (minimal by design) └── init.py
Key design principles:
- Explicit modeling of uncertainty
- Separation between environment dynamics and inference logic
- Deterministic, testable interfaces
- Clear boundaries between modeling and experimentation
from inference.bayesian_network import visualize_bayesian_network
from inference.ghost_tracker import GhostTextWorldExpressEnvThese interfaces are intentionally designed to plug into policy evaluation, belief tracking, or sampling-based inference pipelines.
Exploratory notebooks live in notebooks/ and demonstrate:
- Bayesian network structure and inference behavior
- Effects of noisy observations on hidden-state estimation
- Empirical validation of probability distributions
- Boundary cases and failure modes
All experiments are intentionally decoupled from core logic to preserve testability and reproducibility.
Unit tests in tests/ validate:
- Correctness of probabilistic dependencies
- Inference behavior under controlled conditions
- Robustness of hidden-state environment mechanics
Tests are deterministic and written using pytest, enabling safe refactors
and confident extension of the inference systems.
- Explicit belief state tracking and Bayesian filtering
- Approximate inference techniques (sampling-based methods)
- Integration with reinforcement learning agents
- Larger-scale probabilistic models and environments
- Comparison between exact and approximate inference
This project prioritizes clarity of probabilistic abstractions and correctness of inference over environment-specific heuristics. The architecture is intentionally designed to scale toward more complex machine learning systems that reason under uncertainty.