https://github.com/quantco/metalearners
MetaLearners for CATE estimation
https://github.com/quantco/metalearners
Last synced: about 1 year ago
JSON representation
MetaLearners for CATE estimation
- Host: GitHub
- URL: https://github.com/quantco/metalearners
- Owner: Quantco
- License: bsd-3-clause
- Created: 2024-06-10T20:15:58.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-08T23:00:28.000Z (about 1 year ago)
- Last Synced: 2025-04-02T09:08:24.156Z (about 1 year ago)
- Language: Python
- Homepage: https://metalearners.readthedocs.io/en/latest/
- Size: 1.99 MB
- Stars: 39
- Watchers: 11
- Forks: 4
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# metalearners
[](https://github.com/Quantco/metalearners/actions/workflows/ci.yml)
[](https://metalearners.readthedocs.io/en/latest/?badge=latest)
[](https://anaconda.org/conda-forge/metalearners)
[](https://pypi.org/project/metalearners)
[](https://codecov.io/github/QuantCo/metalearners?branch=main)
MetaLearners for Conditional Average Treatment Effect (CATE) estimation
The library focuses on providing
- Methodologically sound cross-fitting
- Convenient access to and reuse of base models
- Consistent APIs across Metalearners
- Support for more than binary treatment variants
- Integrations with `pandas`, `shap`, `lime`, `optuna` and soon `onnx`
## Example
```python
df = ...
from metalearners import RLearner
from lightgbm import LGBMClassifier, LGBMRegressor
rlearner = RLearner(
nuisance_model_factory=LGBMRegressor,
propensity_model_factory=LGBMClassifier,
treatment_model_factory=LGBMRegressor,
is_classification=False,
n_variants=2,
)
features = ["age", "weight", "height"]
rlearner.fit(df[features], df["outcomes"], df["treatment"])
cate_estimates = rlearner.predict(df[features], is_oos=False)
```
Please refer to our
[docs](https://metalearners.readthedocs.io/en/latest/?badge=latest)
for many more in-depth and reproducible examples.
## Installation
`metalearners` can either be installed via PyPI with
```bash
$ pip install metalearners
```
or via conda-forge with
```bash
$ conda install metalearners -c conda-forge
```
## Development
Development instructions can be found [here](https://metalearners.readthedocs.io/en/latest/development.html).