$ show cdt15/lingam
This repository is the `lingam` Python package, a comprehensive, research-oriented library for causal discovery from observational data using LiNGAM (Linear Non-Gaussian Acyclic Model) and its numerous extensions. It implements over 20 algorithms, including DirectLiNGAM, ICALiNGAM, VAR-LiNGAM, RCD, CAM-UV, RESIT, LiM, mLiNGAM, GroupLiNGAM, MultiGroup variants, and more. The library provides a consistent API where each algorithm exposes `fit()` on a data matrix, followed by properties like `causal_order_` and `adjacency_matrix_`, and all support bootstrap-based stability analysis via a shared `BootstrapMixin`. Key contributions include handling of latent confounders, time series, missing data, mixed data types, and multiple datasets, alongside utilities for causal effect estimation, visualization, model evaluation, and synthetic data generation. The code is well-structured, uses standard scientific Python dependencies (numpy, scipy, scikit-learn, graphviz), and includes a thorough test suite and extensive Jupyter notebook tutorials.
The LLM identified 3 files worth highlighting for reuse:
Provides the `BootstrapMixin` and `BootstrapResult` classes, enabling any causal discovery estimator to perform bootstrap resampling and produce consistent analysis results. `BootstrapMixin.bootstrap()` handles sampling, model fitting, and result aggregation. `BootstrapResult` offers methods like `get_causal_direction_counts()`, `get_directed_acyclic_graph_counts()`, `get_probabilities()`, `get_total_causal_effects()`, and `get_paths()`. This pattern is reusable across any causal discovery project requiring statistical stability assessment.
Implements the Hilbert-Schmidt Independence Criterion (HSIC) with a gamma approximation for the null distribution, providing a fast, kernel-based test for statistical independence. Includes `hsic_test_gamma(X, Y)` and `hsic_test(X, Y)`. The implementation is self-contained and could be extracted for use in any domain requiring non-parametric independence testing (e.g., feature selection, causal discovery, time series analysis).
Implements `CausalBasedSimulator`, a framework for training a causal discovery estimator on real data, then using the learned causal structure to simulate new synthetic data with controlled interventions and noise. It fits a regression model for each variable and can generate counterfactual samples. This component is reusable for any project requiring realistic synthetic data generation based on learned causal graphs, such as benchmarking, augmentation, or sensitivity analysis.