Genriesz: Debiased ML via Riesz Regression
- Genriesz is an open-source Python package for automatic debiased machine learning that implements generalized Riesz regression to estimate causal and structural parameters.
- It leverages the Riesz representation theorem and empirical Bregman divergence minimization to construct cross-fitted estimators with confidence intervals and p-values.
- The package features Automatic Regressor Balancing (ARB) and a modular architecture that simplifies basis selection, generator configuration, and estimator calculation.
genriesz is an open-source Python package for automatic debiased machine learning (DML) with generalized Riesz regression, designed for efficient estimation of causal and structural parameters using the Riesz representation theorem and empirical Bregman-divergence minimization (Kato, 19 Feb 2026). It targets parameters expressible as linear functionals of a regression function, automates construction of compatible representer estimators, and returns regression adjustment, Riesz weighting, augmented Riesz weighting, and TMLE-style estimators with cross-fitting, confidence intervals, and -values. A central design principle is Automatic Regressor Balancing (ARB): given a Bregman generator and a representer model class, the package automatically constructs a compatible link function so that the generalized Riesz regression estimator satisfies balancing, or moment-matching, optimality conditions in a user-chosen basis (Kato, 19 Feb 2026).
1. Statistical target and Riesz-representer formulation
The package operates in an i.i.d. setting with data , feature , outcome , and regression function (Kato, 19 Feb 2026). The estimand is assumed to have the form
where the user-supplied oracle is linear in (Kato, 19 Feb 2026).
By the Riesz representation theorem in , there exists a unique Riesz representer 0 such that
1
for every square-integrable 2 (Kato, 19 Feb 2026). This representation is the organizing device of the package: once 3 is estimated, inference proceeds through a Neyman-orthogonal score,
4
The score is orthogonal, or locally insensitive, to small perturbations of the nuisance functions 5 and 6, and averaging plug-in scores yields a root-7–consistent, asymptotically normal estimator under weak rates plus cross-fitting (Kato, 19 Feb 2026).
This setup places genriesz within the DML tradition while centering estimation of the representer itself. A plausible implication is that the package is especially useful when the main technical bottleneck is not outcome modeling alone, but accurate recovery of the linear functional’s representer under structured balance constraints.
2. Generalized Riesz regression via Bregman divergences
The package implements generalized Riesz regression as estimation of 8 through a pointwise convex generator 9, convex in 0 for each 1, and its associated Bregman divergence
2
The empirical primal loss is, up to additive constants,
3
with 4 a convex penalty, for example an 5 penalty on coefficients (Kato, 19 Feb 2026).
The dual formulation is expressed in the coordinate 6, using the convex conjugate
7
Then the dual loss is
8
which the package describes as often more convenient to optimize (Kato, 19 Feb 2026).
For GLM-style estimation, genriesz approximates the dual coordinate by a linear predictor in a user-specified feature map 9: 0 The fitted coefficient vector solves
1
after which
2
is recovered (Kato, 19 Feb 2026).
This formulation unifies several procedures that the paper explicitly lists as special cases of the framework: covariate balancing, nearest-neighbor matching, calibrated estimation, and density ratio estimation (Kato, 19 Feb 2026).
3. Automatic Regressor Balancing
ARB is the package’s defining methodological principle. The key observation is that if the link is chosen as
3
then the dual coordinate 4 is exactly the linear predictor 5, so no manual link construction is needed (Kato, 19 Feb 2026).
The balancing property arises from the KKT conditions. If
6
then any minimizer 7 satisfies, for each feature 8,
9
For 0, corresponding to the lasso penalty, this yields
1
For 2, the package description states that one gets exact matching up to the multiplier 3. In particular, setting 4 recovers exact balancing in the chosen basis (Kato, 19 Feb 2026).
This makes ARB more than an implementation convenience. It converts the choice of generator 5, basis 6, and penalty 7 into an explicit balance geometry. A plausible implication is that the package can be interpreted as a convex balance engine whose estimand-specific content is supplied through the oracle 8.
4. Software design and representer-model specification
The package exposes a core API centered on a callable target functional, a basis object, and a Bregman generator. The basic pattern is: 2 (Kato, 19 Feb 2026)
The target functional is provided as a Python function or “oracle” of the form 3 and all inner products with the basis 9 are handled automatically (Kato, 19 Feb 2026).
The built-in representer model classes include polynomial bases, treatment-interaction bases, random-forest leaf encodings, neural embeddings, a nearest-neighbor catchment basis, and kernel-feature approximations via random Fourier or Nyström features (Kato, 19 Feb 2026). The specific classes listed are:
PolynomialBasis(degree=k, include_bias=True)TreatmentInteractionBasis(base_basis)genriesz.sklearn_basis.RandomForestLeafBasis(forest_model)genriesz.torch_basis.TorchEmbeddingBasis(torch_nn_module)KNNCatchmentBasis(n_neighbors=M)- kernel-feature approximations via random Fourier or Nyström features
The implemented Bregman generators include SquaredGenerator, UKLGenerator, BKLGenerator, BPGenerator, and PUGenerator; user-defined generators may be supplied by providing g(x,α), grad_g(x,α), inv_grad_g(x,v), and optionally grad2_g (Kato, 19 Feb 2026). The package summary also states that SquaredGenerator corresponds to 0 (Kato, 19 Feb 2026).
The package is available on GitHub and on PyPI, and installation is via 4 (Kato, 19 Feb 2026)
5. Estimators, orthogonalization, and inference
Given cross-fitted estimates 1 and 2, genriesz reports four estimators (Kato, 19 Feb 2026).
Regression Adjustment (RA) is
3
Riesz Weighting (RW) is
4
Augmented Riesz Weighting (ARW) is
5
The TMLE-style procedure updates 6 by a one-dimensional fluctuation along 7, then plugs in the updated regression (Kato, 19 Feb 2026). For Gaussian outcomes,
8
For binary outcomes, the package description states that one solves a small logistic score equation in 9 (Kato, 19 Feb 2026).
Inference is based on 0-fold cross-fitting. The workflow described in the paper is:
5
Under the rate condition
1
the ARW and TMLE estimators are asymptotically normal (Kato, 19 Feb 2026).
This combination of orthogonal scoring and automatic representer estimation suggests that genriesz is built to support both causal and structural functionals without requiring a bespoke orthogonal-score derivation for each new estimand, provided the estimand can be encoded through the oracle 2.
6. Canonical workflows and empirical examples
The package highlights representative workflows for the average treatment effect (ATE), average treatment effect on the treated (ATT), panel difference-in-differences, average marginal effects (AME), and nearest-neighbor matching (Kato, 19 Feb 2026).
For ATE with polynomial features and an unnormalized-KL generator, the documented pattern is: 6 (Kato, 19 Feb 2026)
For ATT and panel DID, the package provides grr_att and grr_did with SquaredGenerator (Kato, 19 Feb 2026). For AME, grr_ame accepts a coordinate index for the derivative target:
7
(Kato, 19 Feb 2026)
The nearest-neighbor matching mode uses riesz_method="nn_matching" and KNNCatchmentBasis, with the note that the basis is unused when outcome_models="none" (Kato, 19 Feb 2026).
These examples illustrate the intended division of labor. The estimand enters through a task-specific wrapper or oracle; the representer model is chosen through a basis; and the balance geometry is controlled by the generator and penalty. This suggests a deliberately modular architecture rather than separate implementations for each estimand.
7. Hyperparameters, scaling, and practical usage
The package description gives specific practical guidance on 3, basis design, and computational scaling (Kato, 19 Feb 2026). In 4-penalized fitting, 5 directly controls the maximum sample imbalance in each basis moment; setting 6 enforces near exact balancing. In 7-penalized fitting, 8 stabilizes the system of equations when the basis is high-dimensional or collinear (Kato, 19 Feb 2026).
For basis selection, low-degree polynomial or random Fourier features are said often to suffice in moderate dimensions. For very large 9, one can embed through a random-forest leaf encoder or a frozen neural network via genriesz.torch_basis; the final Riesz solver remains a convex 0-problem in 1 (Kato, 19 Feb 2026).
On scaling, the core relies on SciPy’s L-BFGS-B for smooth penalties and a smooth approximation of the 2 penalty, and the package description states that it comfortably handles thousands of parameters (Kato, 19 Feb 2026). For very large 3 or 4, suggested mitigations are subsampling, sparse features, and parallel cross-fitting (Kato, 19 Feb 2026).
The paper also includes empirical guidance from usage experiments: if results are unstable, increase 5 or reduce basis dimension; when the true representer is believed sparse in 6, 7 penalty plus small 8 can recover approximate sparsity; and the default squared generator is described as robust and often a good first try, while KL-type generators are suggested when entropy balancing or positivity constraints are desired (Kato, 19 Feb 2026).
In summary, genriesz presents a single coherent interface for defining an estimand 9, choosing a basis 0, picking a Bregman generator 1, and solving the resulting convex generalized Riesz regression problem (Kato, 19 Feb 2026). Its distinguishing contribution is the automation of representer estimation through ARB, coupled with cross-fitted DML-style inference for a family of causal and structural targets.