Examples
The examples directory contains runnable Jupyter notebooks demonstrating mini-causal features. These notebooks provide practical, hands-on examples of how to use the library for various causal analysis tasks.
Available Notebooks
Causal Models (Classifier)
File: examples/causal_models_classifier_example.ipynb
This notebook demonstrates how to compare two classification models using the causality module. Learn how to:
Initialize and configure
CausalModelsClassifierRun causal comparison between models
Interpret the results
Visualize model differences
Key concepts covered:
Causal metrics for model comparison
Statistical tests for causal effects
Practical workflow for model evaluation
Causal Counterfactual
File: examples/mini_causal_causal_counterfactual_example.ipynb
This notebook demonstrates the complete counterfactual workflow using the causal_counter module. Learn how to:
Set up counterfactual analysis
Generate counterfactual explanations
Evaluate counterfactual quality
Interpret the results
Key concepts covered:
Counterfactual generation algorithms
Feature importance through counterfactuals
Model interpretability
Partial Counterfactual (Prostate Dataset)
File: examples/mini_causal_prostate_with_partial_counterfactual.ipynb
This notebook demonstrates targeted counterfactual analysis on the prostate dataset using the partial_counter module. Learn how to:
Focus on specific feature subsets
Run partial counterfactual analysis
Compare results with full counterfactuals
Interpret targeted interventions
Key concepts covered:
Partial counterfactual generation
Feature subset selection
Targeted causal analysis
Domain-specific application
Running the Examples
Prerequisites
Ensure you have Jupyter installed:
pip install jupyter
Optional packages for visualization:
pip install matplotlib seaborn
Launching Jupyter
Navigate to the repository root:
cd mini-causal
Start Jupyter Lab or Notebook:
jupyter lab # or jupyter notebook
Open the notebooks from the
examplesdirectory
Tips for Working with Examples
Start with the classifier example if you’re new to causal analysis
Each notebook includes detailed explanations and code comments
Modify the code to use your own datasets and models
Refer to the module documentation for API details
Note: Some examples may require additional datasets. These are typically included in the datasets directory or will be downloaded automatically.