How z-dragonl/causal-learner works
Project Type and Purpose
• Causal Learner is an open-source research toolbox (not a client/server app) for causal structure and Markov blanket learning.
• It provides:
• R code for simulated Bayesian network data generation
• MATLAB code for global causal structure algorithms (alg_GCS), local causal structure algorithms (alg_LCS), and Markov blanket algorithms (alg_MB)
• Common utility functions and external dependencies (GPML, Feast, MIToolbox)
• Evaluation scripts and example usage
File Structure Analysis
• Top level:
• Code/ – all source code
– Causal_Learner.m – main MATLAB entry point
– Gen_Data/ – R scripts and generated .rds datasets
– alg_GCS/, alg_LCS/, alg_MB/ – algorithm families, each with subdirectories per algorithm
– common/ – shared MATLAB functions and third-party libraries (GPML, Feast, MIToolbox)
– data/ – sample network definitions and datasets
– evaluation/ – evaluation metrics and scripts (SHD, ARRHD, adjacency)
– example_*.m – MATLAB usage examples
• Documentation/ – user manual and copyright
• README.md, LICENSE
Key Insights from README
• R for data generation (Gen_Data) outputs .rds files
• MATLAB for algorithms and evaluation
• Intended extensibility: add new algorithms by dropping new .m files into the correct alg_* folder and invoking them from Causal_Learner.m or example scripts
Components
a. Data Generation (R)
– Gen_Data.R → produces .rds files
– R environment
b. Data Loader (MATLAB)
– Reads .rds via Causal_Learner.m or helper functions
c. Core Algorithm Modules (MATLAB)
– Global Causal Structure (alg_GCS)
– Local Causal Structure (alg_LCS)
– Markov Blanket Learning (alg_MB)
d. Common Utilities & Third-Party Libraries
– common/ (draw_graph, tests, pdag-dag…)
– GPML (used by some GES/KCI tests)
– Feast and MIToolbox (feature selection C-libraries, MATLAB/Java wrappers)
e. Evaluation & Reporting
– evaluation/ scripts → metrics computation
– example_*.m → demonstration flows
f. Documentation & User Interface
– Documentation/ Manual.pdf
– README.md
Relationships and Data Flow
1. User invokes Causal_Learner.m or an example script
2. (Optional) Trigger Gen_Data.R in R → .rds datasets
3. MATLAB Data Loader imports .rds
4. MATLAB core dispatch: select algorithm family (alg_GCS, alg_LCS, alg_MB)
5. Algorithms call common utilities and third-party libs as needed
6. Output learned structures (graphs)
7. Evaluation modules compute SHD/ARRHD/adjacency metrics
8. Results visualized or saved (via draw_graph, example scripts)
Architectural Patterns and Design Principles
• Modular separation by algorithm type (global vs. local vs. MB)
• Shared “common” layer for utilities promoting code reuse
• External dependencies isolated in common/ for GPML, Feast, MIToolbox
• Clear entry points (Causal_Learner.m, example_*.m)
• Data generation separated (R) from algorithm execution (MATLAB)