MCPcopy Index your code
hub / github.com/Quantco/metalearners

github.com/Quantco/metalearners @0.13.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.13.0 ↗ · + Follow
400 symbols 1,964 edges 35 files 100 documented · 25% updated 1d ago0.13.0 · 2025-06-17★ 526 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

metalearners

CI Documentation Status Conda-forge PypiVersion codecov.io

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


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 for many more in-depth and reproducible examples.

Installation

metalearners can either be installed via PyPI with

$ pip install metalearners

or via conda-forge with

$ conda install metalearners -c conda-forge

Development

Development instructions can be found here.

Core symbols most depended-on inside this repo

index_matrix
called by 25
metalearners/_utils.py
safe_len
called by 22
metalearners/_utils.py
metalearner_factory
called by 18
metalearners/utils.py
index_vector
called by 15
metalearners/_utils.py
predict_nuisance
called by 14
metalearners/metalearner.py
_evaluate_model_kind
called by 12
metalearners/metalearner.py
generate_covariates
called by 11
metalearners/data_generation.py
predict_treatment
called by 10
metalearners/metalearner.py

Shape

Function 221
Method 155
Class 22
Route 2

Languages

Python100%

Modules by API surface

metalearners/metalearner.py58 symbols
tests/test_metalearner.py44 symbols
metalearners/_utils.py37 symbols
metalearners/cross_fit_estimator.py23 symbols
tests/test_learner.py22 symbols
tests/test__utils.py22 symbols
tests/conftest.py18 symbols
metalearners/slearner.py18 symbols
metalearners/rlearner.py16 symbols
metalearners/drlearner.py15 symbols
metalearners/xlearner.py12 symbols
tests/test_cross_fit_estimator.py11 symbols

For agents

$ claude mcp add metalearners \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact