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 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 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 (single-basis fits — handles ATE/ATT/TSM via the auto-resolved sieve in Python). The augmentation-style AugForestRieszRegressor is Python-only in v1; call it from R via reticulate when you need a fully estimand-agnostic forest fit.
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(). Integer-typed kwargs (n_estimators, max_depth, random_state, early_stopping_rounds, n_landmarks, n_features, cg_max_iter, min_samples_leaf, subforest_size, epochs, batch_size) take an L suffix in R: n_estimators = 200L. Other kwargs are auto-converted by reticulate.
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: