Lossless Bayesian Networks - Lossless Bayesian Networks
Research Project

Lossless Bayesian Networks in C++

A complete implementation of Bayesian networks with exact inference capabilities, maintaining all probability information without approximation. Includes Objective-C visualization for macOS with precise probability display.

Author Shyamal Chandra
Year 2025
Language C++17

Abstract

This project presents a complete implementation of Bayesian networks in C++ with lossless probabilistic inference. Unlike approximate methods, our implementation maintains exact probability distributions throughout all computations, ensuring precise and deterministic results. The system includes comprehensive DAG validation, efficient CPT management, and a macOS visualization application for interactive exploration of probabilistic models.

Exact inference with variable elimination
Lossless probability representation
Interactive macOS visualization
Lossless belief propagation with influence tracing
Reverse belief propagation for diagnostic reasoning

Key Features

Comprehensive probabilistic reasoning capabilities

01
🎯

Lossless Representation

All probabilities stored and computed exactly without approximation, preserving full precision in all calculations. No rounding errors or numerical approximations.

02
🔬

Exact Inference

Variable elimination algorithm provides precise inference results with deterministic, reproducible outcomes. Guaranteed exactness in all probabilistic queries.

03
🔍

DAG Validation

Automatic cycle detection and topological sorting ensure valid directed acyclic graph structures. Comprehensive error handling for invalid network configurations.

04
📊

Visualization

Interactive macOS app with exact precision display, color-coded nodes, and real-time inference visualization. Explore probabilistic models interactively.

05
⚙️

Flexible API

Easy network construction with comprehensive error handling and support for arbitrary DAG structures. Intuitive interface for building complex probabilistic models.

06
💾

File I/O

Network serialization and loading capabilities for persistent storage and sharing. Save and load complete network configurations with all probability tables.

07
🌊

Lossless Belief Propagation

Sum-product message passing algorithm for exact inference with influence tracing. Trace how probabilities flow through the network and identify causal pathways.

08
🔄

Reverse Belief Propagation

Diagnostic reasoning with lossless reverse tracing. Propagate beliefs from effects to causes, tracing how probabilities flow backwards through the network for diagnostic inference.

Documentation

Complete guides and references

📖
Paper

Main Documentation

Comprehensive guide covering architecture, algorithms, mathematical foundations, and usage examples. Complete technical reference.

Download
📊
Beamer

Presentation

Professional presentation slides covering key concepts, architecture, and examples. Ready for academic presentations.

Download
📚
API

Reference Manual

Complete API documentation with detailed descriptions of all classes, methods, and parameters. Developer reference guide.

Download
🔬
Proofs

Supplementary Material

Extensive mathematical proofs, correctness arguments, and detailed analysis. Includes proofs of factorization, variable elimination, belief propagation, and complexity analyses.

Download

Document Preview

Installation

Get started in minutes

Building the C++ Library

Bash
# Clone the repository
git clone https://github.com/Sapana-Micro-Software/lossless-bayesian-networks.git
cd lossless-bayesian-networks

# Build the project
make

# Run examples
make run

Requirements

  • C++17 compatible compiler (g++, clang++)
  • Make

Building the macOS Visualization App

Bash
# Build the macOS app
make -f Makefile.macos

# Run the app
make -f Makefile.macos run

Requirements

  • macOS 10.13 or later
  • Xcode Command Line Tools
  • clang++ with Objective-C++ support

Examples

See it in action

Medical Diagnosis

Healthcare

Disease diagnosis based on symptoms with exact probability calculations. Demonstrates practical application in medical decision support.

network.addNode("Disease", "Disease", 
                {"None", "Cold", "Flu"});
network.addNode("Symptom", "Fever", {"No", "Yes"});
network.addEdge("Disease", "Symptom");

Alarm Network

Classic

Classic Bayesian network example with burglary, earthquake, and alarm. Standard benchmark for probabilistic inference systems.

network.addNode("Burglary", "Burglary", 
                {"False", "True"});
network.addNode("Alarm", "Alarm", {"False", "True"});
network.addEdge("Burglary", "Alarm");

Belief Propagation

New

Trace influence through the network using lossless belief propagation. See how evidence propagates and affects probabilities throughout the network.

auto result = network.beliefPropagation(
    queryNodes, evidence, true);
auto& beliefs = result.first;
auto& traces = result.second;

Reverse Belief Propagation

New

Diagnostic reasoning with reverse propagation. Given observed effects, infer causes using lossless reverse tracing through the network.

auto result = network.reverseBeliefPropagation(
    queryNodes, evidence, true);
auto& beliefs = result.first;
auto& traces = result.second;