Wrote stuff?

This commit is contained in:
2026-08-29 17:53:06 +03:00
parent 1aef8e0f11
commit 24d6fac79c
9 changed files with 191 additions and 197 deletions
+59
View File
@@ -0,0 +1,59 @@
We instantiate the general ROLL framework (\Cref{sec:roll-formulation}) with Beta-distributed
scores. Beta ROLL applies when model scores are constrained to the open interval $(0,1)$,
as is the case when $f_\theta$ uses a sigmoid output activation. The Beta distribution is
supported on $(0,1)$ and its two shape parameters allow it to capture a wide range of
unimodal and skewed score distributions.
\paragraph{Forward pass.}
Given score vectors $\mathbf{s}^{(k)} \in (0,1)^{|\mathcal{B}_k|}$ for class $k$, let
$\mathbf{t}^{(k)} = \mathbf{1} - \mathbf{s}^{(k)}$ denote the complementary scores.
For any vector $\mathbf{v}$, write $\bar{v} = \frac{1}{|\mathbf{v}|}\sum_i v_i$.
We estimate the shape parameters using the closed-form log-moment estimator
of~\cite{chen2022beta}: define for each class $k$,
\begin{equation}
D_k = \overline{s^{(k)}\!\ln s^{(k)}} - \bar{s}^{(k)}\cdot\overline{\ln s^{(k)}}
+ \overline{t^{(k)}\!\ln t^{(k)}} - \bar{t}^{(k)}\cdot\overline{\ln t^{(k)}}
\label{eq:beta-denom}
\end{equation}
\begin{equation}
\hat{a}_k = \frac{\bar{s}^{(k)}}{D_k}, \qquad \hat{b}_k = \frac{\bar{t}^{(k)}}{D_k}
\label{eq:beta-params}
\end{equation}
These estimators follow from two simultaneous moment conditions:
$\mathbb{E}[X] = a/(a+b)$ and
$\operatorname{Cov}(X,\ln X) + \operatorname{Cov}(Y,\ln Y) = 1/(a+b)$,
where $Y=1-X\sim\operatorname{Beta}(b,a)$.
Replacing expectations by sample means and solving in closed form yields~\eqref{eq:beta-params}.
The CDF of $\operatorname{Beta}(\hat{a}_k,\hat{b}_k)$ at $x\in(0,1)$ is the
regularised incomplete beta function:
\begin{equation}
\hat{F}_k(x) = I_x(\hat{a}_k,\hat{b}_k)
= \frac{B(x;\,\hat{a}_k,\hat{b}_k)}{B(\hat{a}_k,\hat{b}_k)},
\qquad B(x;\,a,b) = \int_0^x u^{a-1}(1-u)^{b-1}\,\mathrm{d}u
\label{eq:beta-cdf}
\end{equation}
Substituting into the general ROLL objective \eqref{eq:roll-tpr-at-fpr}:
\begin{equation}
\mathcal{L}_{\text{ROLL-TPR@FPR}}^{\text{BETA}}(f_\theta(\mathcal{B});\,\alpha)
= I_{\hat\tau}(\hat{a}_1,\hat{b}_1),
\qquad
\hat\tau = I^{-1}_{1-\alpha}(\hat{a}_0,\hat{b}_0)
\label{eq:roll-tpr-at-fpr-beta}
\end{equation}
where $I^{-1}_{1-\alpha}(a,b)$ denotes the $(1-\alpha)$-quantile of $\operatorname{Beta}(a,b)$.
\paragraph{Gradient.}
Unlike the Gaussian case, we do not derive closed-form gradients for Beta ROLL.
The regularised incomplete beta function $I_x(a,b)$ and its inverse are smooth
functions of all their arguments and are available as differentiable operations in
PyTorch (\texttt{torch.special.betainc} and \texttt{torch.special.betaincinv}).
Gradients of \eqref{eq:roll-tpr-at-fpr-beta} with respect to $f_\theta(\mathbf{x}_i)$
are therefore propagated via automatic differentiation through the estimator
\eqref{eq:beta-params}, the CDF evaluation, and the quantile inversion.
+46 -1
View File
@@ -1,3 +1,34 @@
We instantiate the general ROLL framework (\Cref{sec:roll-formulation}) with
Gaussian-distributed scores. Each class's scores are modelled as
$\mathcal{N}(\mu_k, \sigma_k^2)$, fitted by maximum-likelihood estimation.
\paragraph{Forward pass.}
The MLE parameters are:
\begin{equation}
\mu_k = \frac{1}{|\mathcal{B}_k|}\sum_{\mathbf{x}_j \in \mathcal{B}_k} f_\theta(\mathbf{x}_j),
\qquad
\sigma_k^2 = \frac{1}{|\mathcal{B}_k|}\sum_{\mathbf{x}_j \in \mathcal{B}_k}(f_\theta(\mathbf{x}_j)-\mu_k)^2
\end{equation}
The CDF and quantile function of $\mathcal{N}(\mu,\sigma^2)$ are:
\[
F(x) = \tfrac{1}{2}\!\left[1 + \operatorname{erf}\!\left(\tfrac{x-\mu}{\sigma\sqrt{2}}\right)\right],
\qquad
F^{-1}(p) = \mu + \sigma\sqrt{2}\,\operatorname{ierf}(2p-1)
\]
where $\operatorname{erf}(x)=\frac{2}{\sqrt{\pi}}\int_0^x e^{-t^2}\,\mathrm{d}t$ is the Gauss
error function and $\operatorname{ierf}$ its functional inverse.
Substituting into the general ROLL objective \eqref{eq:roll-tpr-at-fpr}:
\begin{align}
\tau &= \mu_0 + \sigma_0\sqrt{2}\,\operatorname{ierf}(1-2\alpha) \nonumber \\
\mathcal{L}_{\text{ROLL-TPR@FPR}}^{\text{GAUSSIAN}}(f_\theta(\mathcal{B});\,\alpha)
&= \tfrac{1}{2}\!\left[1 + \operatorname{erf}\!\left(\tfrac{\tau-\mu_1}{\sigma_1\sqrt{2}}\right)\right]
\label{eq:roll-tpr-at-fpr-gaussian}
\end{align}
\paragraph{Gradient derivation.}
We derive the gradient of \eqref{eq:roll-tpr-at-fpr-gaussian} with respect to
$f_\theta(\mathbf{x}_i)$, instantiating the general structure~\eqref{eq:roll-gradient}
for the Gaussian case. Throughout, $\tau = \hat{F}_0^{-1}(1-\alpha) =
@@ -65,4 +96,18 @@ Therefore:
\label{eq:gauss-grad-y0}
\end{equation}
Substituting \eqref{eq:gauss-grad-y1} and \eqref{eq:gauss-grad-y0} into \eqref{eq:roll-gradient} yields \eqref{eq:gauss-grad-combined}.
Substituting \eqref{eq:gauss-grad-y1} and \eqref{eq:gauss-grad-y0} into \eqref{eq:roll-gradient}:
\begin{equation}
\frac{\partial \mathcal{L}_{\text{ROLL-TPR@FPR}}^{\text{GAUSSIAN}}}{\partial f_\theta(\mathbf{x}_i)} =
\begin{cases}
\dfrac{-1}{|\mathcal{B}_1|\,\sigma_1\sqrt{2\pi}}
\exp\!\left(-\dfrac{(\tau-\mu_1)^2}{2\sigma_1^2}\right)
\!\left(1 + \dfrac{(\tau-\mu_1)(f_\theta(\mathbf{x}_i)-\mu_1)}{\sigma_1^2}\right)
& \text{if } y_i = 1 \\[18pt]
\dfrac{1}{|\mathcal{B}_0|\,\sigma_1\sqrt{2\pi}}
\exp\!\left(-\dfrac{(\tau-\mu_1)^2}{2\sigma_1^2}\right)
\!\left(1 + \dfrac{(\tau-\mu_0)(f_\theta(\mathbf{x}_i)-\mu_0)}{\sigma_0^2}\right)
& \text{if } y_i = 0
\end{cases}
\label{eq:gauss-grad-combined}
\end{equation}