Extracted main text — title through conclusion, appendix excluded. This is what our citation measures are computed over, published so the extraction can be checked by eye.
34,643 characters · 21 sections · 58 citation commands
genriesz: A Python Package for Automatic Debiased Machine Learning with Generalized Riesz Regression
Many targets in causal inference and econometrics can be expressed as linear functionals of an unknown regression function. Prominent examples include the average treatment effect (ATE), the average treatment effect on the treated (ATT), and average marginal effects (AME). Automatic debiased machine learning (ADML) provides general tools for valid inference on such targets Chernozhukov2022automaticdebiased.
The ADML workflow separates the problem into two parts. First, one estimates nuisance components, typically a regression function and a Riesz representer. Second, one plugs these estimates into a Neyman orthogonal score and averages the resulting score over the sample. A Donsker condition or cross-fitting then yields valid inference under weak rate conditions Chernozhukov2018doubledebiased,Klaassen1987consistentestimation.
Various methods have been proposed for Riesz representer estimation, such as Riesz regression Chernozhukov2021automaticdebiased,Chen2015sievesemiparametric, covariate balancing Imai2013covariatebalancing, and density ratio estimation Sugiyama2012densityratio. Kato2026unifiedframework,Kato2025directbias demonstrates a unifying perspective, Riesz representer fitting under Bregman divergences, which is also referred to as generalized Riesz regression, Bregman-Riesz regression, or generalized covariate balancing. Hereafter, we refer to this method as generalized Riesz regression, a name that emphasizes the connection between Riesz representer fitting and balancing weights through the choice of link function. In this framework, one can recover the various methods listed above by specifying particular forms of the Bregman divergence.
Our genriesz package implements generalized Riesz regression for ADML. Users specify the estimand through an evaluation oracle and choose a Riesz representer model and a Bregman generator. The package then constructs a generator-induced link function to deliver automatic regressor balancing, estimates the representer by convex optimization with $\ell_p$ regularization, and reports regression adjustment (RA), Riesz weighting (RW), augmented Riesz weighting (ARW), and targeted maximum likelihood estimation (TMLE)-style estimates with confidence intervals, optionally using cross-fitting Bang2005doublyrobust,vanderLaan2006targetedmaximum.
The flowchart of this automatic procedure is below, where each object will be defined in the subsequent sections (Figure (ref)):
During this process, the user does not need to specify the analytic form of the Riesz representer $\alpha_0$ or the link function $\zeta$. These are constructed from the chosen basis and generator.
\paragraph{Relation to existing software.} The genriesz package complements established DML libraries such as DoubleML Bach2022doublemlpython and EconML Battocchi2019econml, as well as broader causal inference toolkits such as DoWhy Sharma2020dowhy and CausalML Chen2020causalml. These libraries offer rich sets of estimators for canonical causal models and heterogeneous treatment effects. In contrast, genriesz is estimand-and-balancing-centric: the user provides the functional $m$, the representer model, and the specific form of the Bregman divergence, while the package constructs generalized Riesz representers with a link function that yields balancing weights and returns the corresponding estimators. This focus also makes explicit the connection between Riesz representer fitting and balancing weights, including stable weights Zubizarreta2015stableweights and entropy balancing Hainmueller2012entropybalancing, as well as density ratio estimation methods available in specialized packages such as densratio Makiyama2019densratio.
Generalized Riesz regression connects Riesz representer estimation, covariate balancing, and debiased estimation through Bregman divergence minimization. This section summarizes the methodological and theoretical foundations that underlie the software design. Full technical details, proofs, and extensions are provided in Kato2026unifiedframework.
Let $W \coloneqq (X,Y)\sim P$, where $X\in{\mathbb{R}}^d$ is a regressor and $Y\in{\mathbb{R}}$ is an outcome. Let $\gamma_0(x)\coloneqq{\mathbb{E}}\left[Y\mid X=x\right]$. We consider targets of the form
where $m\left(W,\gamma\right)$ is linear in $\gamma$. In genriesz, users supply $m$ as a callable that evaluates $\gamma$ at modified inputs, for example, by switching a treatment component.
Under standard conditions, there exists a Riesz representer $\alpha_0$ such that
The Riesz representer enters the Neyman orthogonal score
which plays a central role in debiased estimation and valid inference under weak conditions, with cross-fitting Chernozhukov2018doubledebiased.
Let $g\left(x,\alpha\right)$ be convex in the scalar $\alpha$ for each fixed $x$. The pointwise Bregman divergence is
Generalized Riesz regression estimates $\alpha_0$ by minimizing an empirical Bregman-Riesz objective of the form
where $\Omega$ is a regularizer, for example an $\ell_p$ penalty on a coefficient vector. Squared-loss generators recover Riesz regression Chernozhukov2021automaticdebiased and series Riesz representer Chen2015sievesemiparametric, while KL-type generators recover tailored-loss, calibrated estimation formulations Zhao2019covariatebalancing,Tan2019regularizedcalbrated and entropy balancing Hainmueller2012entropybalancing. The package provides built-in generators, squared distance (SQ), unnormalized KL (UKL) divergence, binary KL (BKL) divergence, Basu's power (BP) divergence, and PU families, and it also supports user-defined generators.
\paragraph{Dual coordinate and conjugate objective.} A key identity behind the implementation is the conjugacy relation
where $\mathcal{A}(x)$ is the domain of $\alpha$ given $x$. For differentiable generators, $\alpha^*\left(x,v\right)=(\partial_\alpha g)^{-1}\left(x,v\right)$. Using $v(x)\coloneqq \partial_\alpha g\left(x,\alpha(x)\right)$ and $g^*\left(x,v(x)\right)=\alpha(x)v(x)-g\left(x,\alpha(x)\right)$, the objective ((ref)) is equivalent, up to constants, to
This dual view is convenient for optimization and for deriving the balancing optimality conditions.
To fit $\alpha_0$ in a model class, genriesz focuses on GLM-style parameterizations
where $\phi$ is a user-chosen basis and $\zeta$ is a link. A key choice is to set the link to the derivative of the generator,
so that the dual coordinate $v(x)=\partial_\alpha g\left(x,\alpha(x)\right)$ is linear in $\beta$. This is the package's notion of ARB.
In genriesz, the model is estimated by solving a convex program in $\beta$:
After estimating $\widehat{\beta}$, the fitted Riesz representer is $\widehat{\alpha}(x)=\zeta^{-1}\left(x,f_{\widehat{\beta}}(x)\right)$.
Proposition (ref) is a software-relevant consequence of the duality theory in Kato2026unifiedframework. ARB ensures that the solver automatically enforces the correct balancing equations for the user-specified basis, even when the primal model ((ref)) is nonlinear in $\beta$, for example under KL-type links.
The ARB construction ((ref)) makes explicit how generalized Riesz regression recovers classical balancing-weight estimators as dual solutions. Intuitively, the dual variable associated with the linear moment conditions corresponds to per-sample weights, and different generators $g$ induce different weight regularizers. Table (ref) summarizes common choices implemented in genriesz, see Kato2026unifiedframework for precise statements.
\paragraph{Domain constraints and branch selection.} Some generators require constraints such as $\left|\alpha\right|>C$ and $\alpha\in\left(0,1\right)$. genriesz exposes a branch_fn interface that selects a valid branch, for example treated versus control, so that the fitted representer respects the generator domain by construction.
Given nuisance estimates $\widehat{\gamma}$ and $\widehat{\alpha}$, optionally cross-fitted, genriesz outputs four plug-in estimators, regression adjustment (RA), Riesz weighting (RW), augmented Riesz weighting (ARW), and targeted maximum likelihood estimation (TMLE)-style estimators, defined as follows:
In TMLE, $\widehat{\gamma}^{(1)}$ is a one-dimensional fluctuation update of $\widehat{\gamma}$ along the direction $\widehat{\alpha}$. We consider two likelihood choices, Gaussian and Bernoulli with a logit link, which lead to different update maps for $\widehat{\gamma}^{(1)}$. See Appendix (ref).
\paragraph{Inference.} For each estimator, genriesz computes Wald-type standard errors from the empirical variance of the corresponding estimated influence-function scores. Cross-fitting is recommended in high-capacity settings Chernozhukov2018doubledebiased.
The design goal of genriesz is to separate statistical intent, the functional $m$ and the representer class, from numerical implementation, basis matrices, generator derivatives, solvers, and cross-fitting.
The main entry point is grr_functional:
The returned result object stores point estimates, standard errors, confidence intervals, $p$-values, and optional out-of-fold nuisance predictions.
\paragraph{Estimators, cross-fitting, and outcome models.} The estimators argument selects which plug-in estimators to report. The built-in names follow the genriesz naming convention, "ra" for regression adjustment, "rw" for Riesz weighting, "arw" for augmented Riesz weighting, and "tmle" for the TMLE-style update. Cross-fitting is enabled by \texttt{cross_fit=True} with \texttt{folds} controlling the number of folds.
For RA, ARW, and TMLE, the package needs an outcome regression model $\widehat{\gamma}$. Users can control its construction by outcome_models, for example, "shared" fits a linear model using the same basis and regularization interface as the Riesz model, while "separate" fits the same outcome regression on a user-supplied outcome basis outcome_basis. Setting outcome_models="none" skips outcome modeling, then only RW is available.
For common causal estimands with a binary treatment indicator $D$ stored in a column of $X$, the package provides convenience wrappers that call grr_functional with predefined $m$:
These wrappers reduce boilerplate for standard workflows while still exposing basis and generator choices.
The genriesz package treats the representer model as linear in a user-specified feature map $\phi(x)$. The core module includes polynomial features and treatment-interaction features for ATE and ATT workflows, as well as RKHS-style approximations via random Fourier features and Nystr\"om features.
Two optional modules expand the basis library: (i) genriesz.sklearn_basis provides a random forest leaf one-hot basis that turns a fitted ensemble into a sparse feature map, and (ii) genriesz.torch_basis wraps a PyTorch embedding network as a frozen feature map.
Finally, genriesz provides a kNN catchment basis KNNCatchmentBasis and matching utilities in genriesz.matching, which connect nearest-neighbor matching to squared-loss Riesz regression Kato2025nearestneighbor,Lin2023estimationbased.
\paragraph{Feature maps.} Keeping the solver linear in $\beta$ in the dual coordinate preserves convexity and the exact ARB optimality conditions in Proposition (ref). This suggests a practical pattern for neural pipelines, learn an embedding, freeze it, and then fit the representer in the induced feature space.
The GLM solver supports $\ell_p$ penalties for any $p\ge 1$.
\paragraph{Penalty interface.} For the Riesz model, set riesz_penalty="l2" for ridge, riesz_penalty="l1" for lasso, and riesz_penalty="lp" with riesz_p_norm=p for general $p\ge 1$. A shorthand such as riesz_penalty="l1.5" is also supported. When using the default linear outcome regression, the same interface is available via outcome_penalty and \texttt{outcome_p_norm}.
For $p\ge 1$, genriesz uses L-BFGS-B via SciPy, with a smooth approximation of the $\ell_1$ subgradient when $p=1$. The solver exposes iteration limits and tolerances, but defaults aim to work out-of-the-box for moderate feature dimensions.
genriesz is designed around a simple data interface: X is a NumPy array of shape $\left(n,d\right)$ and Y is a vector of shape $\left(n,\right)$. The meaning of columns of X is left to the user and to the functional object.
\paragraph{Binary treatment conventions.} For wrappers for ATE, ATT, and DID estimation, the treatment indicator $D$ is assumed to be binary and stored at a known column index of X. The user can freely choose the remaining covariates $Z$.
\paragraph{Panel DID.} For grr_did, the package expects two outcome vectors Y0 and Y1 representing pre and post outcomes for the same units and computes $\Delta Y \coloneqq Y_1-Y_0$ internally.
\paragraph{Sampling and inference.} The default inference uses an i.i.d. approximation and Wald-type confidence intervals. As with standard DML software, clustered or dependent data require user-supplied adaptations, for example cluster-robust variance estimators, which are not yet part of the core release.
The repository includes runnable scripts and Jupyter notebooks illustrating the workflows below.
Let $X=\left[D,Z\right]$ and choose a polynomial basis with treatment interactions:
ATT and panel DID are available via wrapper functions:
Average marginal effects can be computed when the chosen basis implements derivatives:
Nearest-neighbor matching weights can be computed using the built-in matching Riesz method:
\paragraph{Availability and installation.} The package is available on PyPI and can be installed by pip install genriesz. The package is also available on GitHub \url{https://github.com/MasaKat0/genriesz}. Optional extras enable scikit-learn-based and PyTorch-based bases. The documentation is hosted at \url{https://genriesz.readthedocs.io}.
\paragraph{Dependencies.} The core package depends only on NumPy and SciPy Harris2020arrayprogramming,Virtanen2020scipy10. Optional extras provide scikit-learn-based tree feature maps and PyTorch-based neural feature maps Pedregosa2011scikitlearn,Buitinck2013apidesign,Paszke2019pytorchan.
\paragraph{Quality control.} The project includes unit tests, type hints, and continuous integration to catch regressions. The software is released under the GNU General Public License v3.0 (GPL-3.0).
\paragraph{Debiased ML and causal ML libraries.} DoubleML Bach2022doublemlpython,Bach2024doublemlr and EconML Battocchi2019econml provide production-quality implementations of canonical DML estimators, with a focus on treatment effect estimation and, in EconML, heterogeneous effects. DoWhy Sharma2020dowhy provides an end-to-end causal inference interface centered on causal graphs. CausalML Chen2020causalml offers a broad suite of uplift modeling and heterogeneous effect estimators.
genriesz is complementary. It targets low-dimensional linear functionals with valid inference via orthogonalization and emphasizes representer estimation and balancing. This estimand-centric API makes it convenient to prototype new targets by defining only the oracle $m$, while keeping the representer fitting problem explicit.
\paragraph{Balancing-weight and density ratio toolkits.} Several toolkits implement specific balancing-weight estimators, such as entropy balancing or stable weights, for ATE-like problems. Density ratio estimation packages such as densratio Makiyama2019densratio implement methods such as uLSIF, RuLSIF, and KLIEP. genriesz connects these approaches to Riesz representer estimation and DML-style inference through a single interface.
The genriesz package provides an estimand-and-balancing-centric implementation of ADML via generalized Riesz regression under Bregman divergences. By unifying Riesz representer fitting, automatic regressor balancing, and debiased estimation behind modular abstractions, the package aims to make ADML practical for a wide range of causal and structural parameter estimation problems.
,