A Python package demonstrating causal inference methods through a coffee shop business case study.
- Synthetic data generation for coffee shop sales
- Multiple causal inference methods:
- Correlation Analysis
- Instrumental Variables (IV)
- Double Machine Learning (DML)
- Transfer Entropy
- Interactive visualizations
- Story-driven Jupyter notebooks
- Documentation using Sphinx
- Comprehensive test suite
- Clone the repository:
git clone https://github.com/yourusername/coffee_causality.git
cd coffee_causality
- Create and activate virtual environment:
# Windows
python -m venv venv
.\venv\Scripts\activate
# Linux/Mac
python -m venv venv
source venv/bin/activate
- Install dependencies:
pip install -r requirements.txt
- Set up Jupyter kernel:
python -m ipykernel install --user --name=coffee_causality_venv --display-name "Python (coffee_causality)"
coffee_causality/
├── .github/ # GitHub Actions workflows and templates
├── book/ # Documentation and tutorials
├── docs/ # Sphinx documentation
│ ├── build/ # Generated documentation
│ ├── source/ # Documentation source files
│ ├── Makefile # Documentation build script
│ └── conf.py # Sphinx configuration
├── notebooks/ # Jupyter notebooks
│ ├── A_Problem_Definition.ipynb # Problem setup and data generation
│ ├── B_Initial_Analysis.ipynb # Basic statistical analysis
│ ├── C_Advanced_Analysis.ipynb # Advanced causal methods
│ └── D_Transfer_Entropy.ipynb # Information flow analysis
├── plots/ # Generated visualizations
├── results/ # Analysis results and outputs
├── src/ # Source code
│ ├── __init__.py
│ ├── data_generator.py # Synthetic data generation
│ ├── causal_analysis.py # Causal inference implementations
│ └── visualization.py # Visualization tools
├── .gitignore # Git ignore rules
├── LICENSE # GPLv3 License
├── README.md # This file
└── requirements.txt # Project dependencies
data_generator.py
: Creates synthetic coffee shop data with hidden confounderscausal_analysis.py
: Implements various causal inference methodsvisualization.py
: Provides visualization tools for analysis results
- API Reference
- Implementation details
- Usage guides and tutorials
- Example notebooks
- Step-by-step analysis examples
- Interactive visualizations
- Results interpretation
-
Data Processing
- numpy: Numerical computing
- pandas: Data manipulation
-
Visualization
- matplotlib: Basic plotting
- seaborn: Statistical visualizations
- networkx: Network analysis
-
Machine Learning
- scikit-learn: Machine learning utilities
- econml: Double ML implementation
-
Causal Analysis
- statsmodels: Statistical modeling
- IDTxl: Information theory
-
Development
- jupyter: Notebook interface
- pytest: Testing framework
- sphinx: Documentation generation
- sphinx-rtd-theme: Documentation theme
The documentation is built using Sphinx and can be found in the docs/
directory. To build the documentation:
cd docs
make html
The built documentation will be available in docs/build/html/index.html
.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing_feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing_feature
) - Open a Pull Request
This project is licensed under the GPLv3 License - see the LICENSE file for details.