Install

rieszreg holds the shared abstractions; pick at least one implementation package for an actual learner.

Python

All six packages live in one GitHub repo, rieszreg/rieszreg, under packages/:

Package Learner
rieszreg shared estimands, losses, and sklearn glue
rieszboost gradient boosting
krrr kernel ridge regression
forestriesz random forests
riesztree a single decision tree
riesznet neural networks

The repo is a uv workspace. One command installs every package into .venv/ at the repo root:

git clone https://github.com/rieszreg/rieszreg.git
cd rieszreg
uv sync --all-packages --all-extras --all-groups

--all-groups adds the docs dependency group (causaldata, matplotlib, and a few others). The real-data examples need it: packages/rieszboost/examples/lalonde_ate.py, packages/rieszboost/examples/nhefs_shift.py, and the custom estimation page load their data from causaldata. Leave the flag off if you only need the learners.

rieszboost’s XGBoostBackend requires OpenMP. On macOS:

brew install libomp

Linux distributions (and GitHub Actions ubuntu-latest) ship libgomp1; no extra step is needed. krrr has no system prerequisites. forestriesz depends on econml, which ships prebuilt wheels for macOS arm64+x86_64 and ubuntu — no compiler required. riesztree (which forestriesz also uses) builds a small Cython extension during install, so it needs a C compiler (Xcode command-line tools on macOS, gcc on Linux). riesznet depends on torch>=2.0; CPU wheels are fetched automatically, GPU wheels need a --index-url per the PyTorch install matrix.

Combining rieszboost and riesznet in one process

The macOS pip wheels for xgboost and torch each bundle their own libomp.dylib. When both are loaded into one Python process, the two OpenMP runtimes can deadlock during a fit (troubleshooting). Two install paths avoid this:

  • conda-forge — installs xgboost and pytorch against a single shared llvm-openmp, so the conflict cannot occur:

    conda install -c conda-forge xgboost pytorch
    pip install -e packages/rieszreg/python packages/rieszboost/python packages/riesznet/python
  • thread-limit env vars — keep the uv install above and set OMP_NUM_THREADS=1 (and MKL_NUM_THREADS=1) in the shell or at the top of every script that uses both backends. See the troubleshooting page for the full discussion and options including threadpoolctl.threadpool_limits for finer-grained control.

Verify

The chunks below import each package and exercise its public entry point. Failure to import or instantiate raises immediately.

import importlib.metadata as _md
import rieszreg, rieszboost, krrr, forestriesz, riesztree, riesznet
from rieszreg import ATE
from rieszboost import RieszBooster
from krrr import KernelRieszRegressor
from forestriesz import AugForestRieszRegressor, ForestRieszRegressor
from riesztree import RieszTreeRegressor
from riesznet import RieszNet

# Construct one estimator from each backend to confirm wiring.
estimand = ATE()
RieszBooster(estimand=estimand, n_estimators=5)
RieszBooster(estimand=<rieszreg.estimands.base.ATE object at 0x1608b8c20>,
             n_estimators=5)
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
KernelRieszRegressor(estimand=estimand, lambda_grid=(1e-2,))
KernelRieszRegressor(estimand=<rieszreg.estimands.base.ATE object at 0x1608b8c20>,
                     lambda_grid=(0.01,))
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
AugForestRieszRegressor(estimand=estimand, n_estimators=10)
AugForestRieszRegressor(estimand=<rieszreg.estimands.base.ATE object at 0x1608b8c20>,
                        n_estimators=10)
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
ForestRieszRegressor(estimand=estimand, n_estimators=10)
ForestRieszRegressor(estimand=<rieszreg.estimands.base.ATE object at 0x1608b8c20>,
                     n_estimators=10)
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
RieszTreeRegressor(estimand=estimand)
RieszTreeRegressor(estimand=<rieszreg.estimands.base.ATE object at 0x1608b8c20>)
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
RieszNet(estimand=estimand, hidden_sizes=(8,), epochs=1)
RieszNet(epochs=1, estimand=<rieszreg.estimands.base.ATE object at 0x1608b8c20>,
         hidden_sizes=(8,))
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
for pkg in ("rieszreg", "rieszboost", "krrr", "forestriesz", "riesztree", "riesznet"):
    print(f"{pkg:<12} {_md.version(pkg)}")
rieszreg     0.0.1
rieszboost   0.0.1
krrr         0.0.1
forestriesz  0.0.1
riesztree    0.0.1
riesznet     0.0.1
# `_setup.qmd` already dev-loaded rieszreg + rieszboost. Reference the
# exported symbols and instantiate one R6 wrapper to confirm reticulate
# is wired through to the Python venv.
stopifnot(is.function(ATE), R6::is.R6Class(RieszBooster))
booster <- RieszBooster$new(estimand = ATE(), n_estimators = 5L)
cat("rieszreg + rieszboost R wrappers OK (",
    class(booster)[1], ")\n", sep = "")
rieszreg + rieszboost R wrappers OK (RieszBooster)

R wrappers (optional)

The R packages are R6 wrappers that call the Python implementations through reticulate. They do not require any separate algorithmic dependency.

First-time setup:

  1. Install the R package dependencies:

    install.packages(c(
      "reticulate", "R6",          # required: Python bridge + R6 classes
      "pkgload",                   # required for `pkgload::load_all` below
      "rsample", "xgboost"         # optional: used in the landing-page R quickstart
                                   # and the estimation/custom-code page
    ))
  2. Install the six R packages from the repo root:

    Rscript tools/r/install.R              # all six
    Rscript tools/r/install.R rieszboost   # rieszreg + one learner package

    Then library(rieszreg); library(rieszboost) in R. To dev-load from the source tree instead, run from the repo root and load rieszreg first, since every learner package imports from it:

    pkgload::load_all("packages/rieszreg/r/rieszreg")
    pkgload::load_all("packages/rieszboost/r/rieszboost")
    pkgload::load_all("packages/krrr/r/krrr")
    pkgload::load_all("packages/forestriesz/r/forestriesz")
    pkgload::load_all("packages/riesztree/r/riesztree")
    pkgload::load_all("packages/riesznet/r/riesznet")

    Load rieszboost and riesznet in separate R sessions on macOS (see Combining rieszboost and riesznet in one process).

  3. Point reticulate at the uv venv before loading any package. Set the environment variable before R starts:

    export RETICULATE_PYTHON=/path/to/rieszreg/.venv/bin/python

    Or call use_python_rieszboost(".venv/bin/python") (each package has its own use_python_<pkg>()).

The R API exposes every built-in estimand, every loss, and the full estimator interface for each backend. The symbolic tracer for custom m() is Python-only; see r-interface for how to call it from R.

Tests

Run each Python test suite separately from the repo root:

for pkg in rieszreg rieszboost krrr forestriesz riesztree riesznet; do
  uv run pytest "packages/$pkg/python/tests" -q
done

The R tests use the R packages installed in step 2 above. Run riesznet in its own R session:

export RETICULATE_PYTHON=$PWD/.venv/bin/python
Rscript -e '
  library(rieszreg)
  for (pkg in c("rieszboost", "krrr", "forestriesz", "riesztree")) {
    library(pkg, character.only = TRUE)
    testthat::test_dir(file.path("packages", pkg, "r", pkg, "tests", "testthat"))
  }
'
Rscript -e '
  library(rieszreg); library(riesznet)
  testthat::test_dir("packages/riesznet/r/riesznet/tests/testthat")
'