Oguzz07/causal-discovery-algorithm-selection
2
Causal Discovery Algorithm Selection Meta-Learner
A meta-learning system that predicts the top-3 best causal discovery algorithms for any discrete observational dataset, based on dataset meta-features.
๐ฏ What it Does
Given a new discrete dataset (pandas DataFrame), the system:
- Extracts 34 meta-features (entropy, mutual information, chiยฒ statistics, CI test probes, etc.)
- Predicts normalized SHD for each of 9 algorithms via trained models
- Ranks and returns the top-3 algorithms expected to produce the most accurate CPDAG
๐ Performance (Leave-One-Network-Out Cross-Validation)
Best Model: Pairwise-GBM Ranking
Model Comparison (178 configs, 14 networks + augmented)
Progression
๐งช Algorithm Pool (9 algorithms)
๐ฌ Key Insight: Dependency Parsing Connection
This project was inspired by a structural parallel between NLP dependency parsing and causal discovery:
- Both predict directed graphs over nodes (words/variables)
- Both have ground-truth annotations (treebanks/bnlearn networks)
- Both use arc-level evaluation (UAS/LAS โ SHD/F1)
The biaffine pairwise scoring mechanism from Dozat & Manning (2017) was independently reinvented by AVICI and CauScale for causal structure learning โ validating this connection.
Top Predictive Meta-Features
n_variables(30%) โ network size (how many nodes in the graph)max_pairwise_MI(24%) โ strongest pairwise dependency (โ biaffine arc score)max_cramers_v(8%) โ strongest association strengthmax_entropy(7%) โ variable complexity
Three Ideas Borrowed from Parsing
- Biaffine-style pairwise features: MI and Cramรฉr's V between all variable pairs = parsing's arc scores
- Pairwise ranking (our best model): For each algorithm pair (A,B), predict which wins โ count wins to rank. Inspired by pairwise tournament-style parser selection
- Cross-domain transfer: Train on well-characterized bnlearn networks โ predict on new unseen datasets (= cross-lingual parser transfer)
๐ Quick Start
from causal_selection.meta_learner.predictor import predict_best_algorithms
import pandas as pd
# Load your discrete dataset
df = pd.read_csv("my_discrete_data.csv")
# Get top-3 recommendations
result = predict_best_algorithms(df, k=3)
# Prints ranked algorithms with predicted accuracy and confidence๐ Project Structure
causal_selection/
โโโ data/
โ โโโ generator.py # Load bnlearn networks, sample data, DAGโCPDAG
โ โโโ bif_files/ # 14 bnlearn BIF files (asia through win95pts)
โ โโโ results/ # Benchmark CSVs: meta-features, SHD matrices
โโโ discovery/
โ โโโ algorithms.py # 9 algorithm adapters with timeout handling
โ โโโ evaluator.py # SHD, F1, Precision, Recall computation
โโโ features/
โ โโโ extractor.py # 34 meta-features across 5 tiers
โโโ meta_learner/
โ โโโ trainer.py # Multi-Output RF/GBM + LONO-CV evaluation
โ โโโ predictor.py # Inference: dataset โ top-3 prediction
โโโ models/
โ โโโ meta_learner.pkl # Trained GBM (multi-output fallback)
โ โโโ pairwise_model.pkl # Pairwise ranking GBM (best model)
โ โโโ scaler.pkl # Feature scaler
โโโ benchmark.py # Full benchmark orchestration
โโโ run_benchmark.py # Resumable benchmark runner
โโโ augment_and_improve.py # Data augmentation + model improvement๐ Benchmark Data
- 14 bnlearn networks: asia, cancer, earthquake, sachs, survey, alarm, barley, child, insurance, mildew, water, hailfinder, hepar2, win95pts
- 178 dataset configs: 122 original + 56 augmented (variable subsampling, sample-size variation, noise injection)
- 1,600+ algorithm runs: 9 algorithms ร 178 configs with per-algorithm timeout
Data Augmentation Strategies
- Variable subsampling: Drop 20-40% of variables to create virtual sub-networks
- Sample-size variation: Generate N=300, 750, 1500, 3000 for each network
- Noise injection: Randomly flip 5-10% of categorical values
๐ง Dependencies
causal-learn>=0.1.4
pgmpy>=0.1.25
scikit-learn>=1.8
pandas
numpy
scipy
joblib๐ References
- Causal-Copilot (arxiv:2504.13263) โ Closest existing algorithm selection system
- AVICI (arxiv:2205.12934) โ Amortized causal structure learning (biaffine architecture)
- CauScale (arxiv:2602.08629) โ Scalable neural causal discovery
- Dozat & Manning (arxiv:1611.01734) โ Deep Biaffine Attention for dependency parsing
- TreeCRF (arxiv:2005.00975) โ Global structural training loss for parsing
- SATzilla (arxiv:1401.2474) โ Algorithm selection via meta-learning
- bnlearn (bnlearn.com) โ Bayesian network benchmark repository
๐ฎ Future Work (Phase 2)
- Biaffine neural encoder: Pre-train a neural feature extractor that learns variable-pair "arc scores"
- Portfolio regret loss (TreeCRF-inspired): Global ranking optimization instead of per-algorithm MSE
- Hyperparameter co-selection: Predict not just which algorithm but optimal hyperparameters (CASH)
- Ensemble prediction: Run top-3 and vote on edges across their CPDAGs
License
MIT
