Each implementation package ships an R6 wrapper that calls the Python implementation through reticulate. Predictions are bitwise-identical to the Python results on the same input.
The R API is covered throughout the guide via the bilingual tabsets: see install for setup, the landing-page quickstart for the standard fit pattern, and estimands for the full estimand inventory. This page is the focused R reference.
Setup
After installing the Python packages (see install):
# Option A: env var, set before R startsSys.setenv(RETICULATE_PYTHON ="/path/to/RieszReg/.venv/bin/python")# Option B: explicit, after R has starteduse_python_rieszboost("/path/to/RieszReg/.venv/bin/python")# or, for the kernel backend:use_python_krrr("/path/to/RieszReg/.venv/bin/python")# or, for the forest backend:use_python_forestriesz("/path/to/RieszReg/.venv/bin/python")# or, for the single-tree backend:use_python_riesztree("/path/to/RieszReg/.venv/bin/python")# or, for the neural backend:use_python_riesznet("/path/to/RieszReg/.venv/bin/python")
use_python_<pkg>() accepts a path to a Python interpreter or a virtualenv directory and forwards to the appropriate reticulate function. It also imports the Python package so subsequent calls have no per-call import overhead.
.predict_interval(Z, alpha=) (single-basis fits, i.e. TSM, with honest=TRUE, inference=TRUE)
$diagnose(df)
.diagnose(Z)
load_forest_riesz_regressor(path)
ForestRieszRegressor.load(path)
The R wrapper exposes the moment-style ForestRieszRegressor. It handles ATE, ATT and TSM through the default treatment-indicator basis. The augmentation-style AugForestRieszRegressor is Python-only in v1; call it from R via reticulate when you need a fully estimand-agnostic forest fit.
categorical_features takes column names, or 1-based positions in the estimand’s input columns (treatment first). max_features follows Python: an R integer (3L) or a whole number above 1 is a feature count, and a fraction in \((0, 1]\) or a string such as "sqrt" is passed as is, so max_features = 1 means all features.
The R wrapper exposes the simple-MLP convenience surface only. Custom torch architectures (custom nn.Module factory, custom optimizer, custom scheduler) are Python-only — define the factory in Python at module top level and call into Python via reticulate. TorchBackend direct construction is also Python-only in v1.
R6’s $method() syntax maps to Python’s .method(). The wrappers convert integer-typed arguments (n_estimators, max_depth, random_state, epochs, and so on) with as.integer(), so n_estimators = 200 and n_estimators = 200L both work. Other arguments are converted by reticulate.
Data frames are converted to pandas column by column. Numeric and logical columns pass through as numbers. Factor columns are converted through their labels, so a treatment coded factor(c("0", "1")) arrives as 0/1. ATE and ATT need the treatment coded 0/1 and stop with an error otherwise.
Parity
The same fit produces the same predictions in both languages. The R test suites verify this with tolerance = 1e-12.
The two columns above use different RNGs (default_rng(0) versus set.seed(0)), so the df and the predictions differ between tabs. To verify parity end-to-end, fit on the same data in both languages and compare predictions row-by-row.
Cross-fitting and tuning from R
Use rsample::vfold_cv for splits and a for loop over $fit() / $predict() / $score() on the R6 estimator. See Tuning and cross-fitting for full examples.
Custom Python objects from R
The LinearForm tracer is Python-only. To use a custom estimand or Loss subclass from R, define it in Python via reticulate: