It's done first draft wahoo

This commit is contained in:
2026-08-31 23:58:01 +03:00
parent 275e29bde0
commit d217b2356a
10 changed files with 90 additions and 100 deletions
+11 -12
View File
@@ -9,7 +9,7 @@
% This section establishes the notation and primary objective used throughout the chapter.
Given a dataset $\mathcal{D} = \{(\mathbf{x}_i, y_i)\}_{i=1}^{n}$ with inputs
$\mathbf{x}_i \in \mathcal{X}$ and binary labels $y_i \in \{0, 1\}$, we learn a
scoring function $f_\theta : \mathcal{X} \to \mathbb{R}$ by fitting.
scoring function $f_\theta : \mathcal{X} \to \mathbb{R}$ by minimising a surrogate loss on $\mathcal{D}$.
The positive and negative subsets of $\mathcal{D}$ are:
\[
\mathcal{D}_1 = \{(\mathbf{x}_i, y_i) \in \mathcal{D} \mid y_i = 1\},
@@ -46,12 +46,12 @@ surrogates for both the AUC objective \eqref{eq:objective-auc} and these point o
\label{sec:roll-framework}
In order to allow gradient-based learning methods to optimize AUC directly, we introduce
ROLL --- Rate Optimized Likelihood Loss.
ROLL, Rate Optimized Likelihood Loss.
The core idea of ROLL is as follows: at each training step, differentiable distributions
are fitted to the positive- and negative-class score outputs of $f_\theta$. AUC is then
approximated by evaluating the estimated $\operatorname{TPR}$ at 99 evenly-spaced
$\operatorname{FPR}$ values across $(0,1)$ and averaging --- a numerical integration of
$\operatorname{FPR}$ values across $(0,1)$ and averaging, a numerical integration of
the ROC curve. Because each per-threshold evaluation is differentiable through the fitted
distributions, this AUC approximation can be maximized directly by gradient descent, with
no threshold selection required at inference time.
@@ -75,7 +75,7 @@ In practice, however, making these evaluations differentiable is not straightfor
Directly optimizing TPR for FPR, or vice versa, is a non-differentiable problem.
For this sub-section, we will reffer to an example of maximizing TPR given a fixed FPR,
For this sub-section, we will refer to an example of maximizing TPR given a fixed FPR,
though this can be reversed.
For any loss $\mathcal{L}(\theta)$, in order
@@ -99,7 +99,7 @@ by some $\varepsilon$ will not affect either TPR or FPR at all, and the derivati
if $f_\theta(\mathbf{x}_i) = \tau$, the derivative of TPR/FPR w.r.t.\ $f_\theta(\mathbf{x}_i)$ becomes infinite. This derivative cannot be used
to continuously fit our model.
This necessitates a different approach, to make these calculations differentiable w.r.t the scores themselves, in order to fit this type of optimization into a learning platform.
This necessitates a different approach, to make these calculations differentiable w.r.t.\ the scores themselves, in order to fit this type of optimization into a learning platform.
\subsection{Score Distribution Fitting as a Solution}
\label{sec:score-distribution-fitting}
@@ -198,9 +198,8 @@ inner structure: each evaluates one empirical CDF at the $(1-\alpha)$-quantile o
The two objectives are interchangeable at the implementation level: replacing
$f_\theta(\mathbf{x})$ with $-f_\theta(\mathbf{x})$ and $y$ with $1 - y$ swaps the roles
of the two populations, and passing target rate $1-\alpha$ to the resulting
TPR@FPR objective recovers the FPR@TPR objective at rate $\alpha$. Because
the two objectives are therefore interchangeable at the implementation level, all derivations
and implementation details below are given for \eqref{eq:roll-tpr-at-fpr} only;
TPR@FPR objective recovers the FPR@TPR objective at rate $\alpha$. All derivations
and implementation details below are therefore given for \eqref{eq:roll-tpr-at-fpr} only;
\eqref{eq:roll-fpr-at-tpr} follows by the same transformation applied to the inputs, with
the target rate complemented to $1-\alpha$.
\Cref{fig:roll-principle} provides a geometric view of \eqref{eq:roll-tpr-at-fpr}.
@@ -213,7 +212,7 @@ the target rate complemented to $1-\alpha$.
threshold $\tau$ (dashed) is placed at the $(1-\alpha)$-quantile of the negative
class, so that exactly $\alpha$ fraction of negative scores exceed it ($\operatorname{FPR}=\alpha$).
The shaded area under the positive-class PDF to the left of $\tau$ is
$\hat{F}_1(\tau)$ --- the ROLL loss we minimize. Tick marks along the bottom represent
$\hat{F}_1(\tau)$, the ROLL loss we minimize. Tick marks along the bottom represent
observed positive-class scores. \textit{Lower}: corresponding CDFs $\hat{F}_0$ (blue)
and $\hat{F}_1$ (orange). Reading horizontally at height $1-\alpha$ on $\hat{F}_0$
gives $\tau$; reading $\hat{F}_1(\tau)$ off $\hat{F}_1$ at the same $\tau$ gives the
@@ -406,7 +405,7 @@ The derivation is given in Appendix~\ref{appendix:kde-grad}; letting $\tau = \ha
where $\tau = \hat{F}_0^{-1}(1-\alpha ; \mathcal{B}_0)$.
The explicit sigmoid-kernel form of \eqref{eq:kde-grad-combined} — forward pass CDF, efficient gradient, and implementation notes — is given in Appendix~\ref{appendix:kde-sigmoid}.
The explicit sigmoid-kernel form of \eqref{eq:kde-grad-combined}, forward pass CDF, efficient gradient, and implementation notes, is given in Appendix~\ref{appendix:kde-sigmoid}.
Positive-class samples are weighted by their individual kernel
PDF at $\tau$; negative-class samples are weighted by the mean positive-class kernel
PDF scaled by each sample's share of the negative-class kernel mass.
@@ -561,7 +560,7 @@ The scaling has no effect on the loss value itself or derived gradients.
Silverman's rule derives the bandwidth proportionally to the data standard deviation,
$h \propto \hat\sigma \cdot n^{-1/5}$, so dividing all scores by $\hat\sigma_\mathcal{B}$
causes the bandwidth to scale by the same factor.
The product $v \cdot (\tau - s_j)$ — the only quantity entering the sigmoid — is
The product $v \cdot (\tau - s_j)$ (the only quantity entering the sigmoid) is
therefore invariant under the rescaling.
In the backward pass, gradients with respect to the normalised scores are multiplied
by $1/\hat\sigma_\mathcal{B}$ to apply the chain rule, providing gradients mathematically
@@ -586,7 +585,7 @@ nearest-threshold samples.
We estimate the bandwidth using the Improved Sheather-Jones (ISJ)
method~\cite{botev2010kde}, which minimises the asymptotic mean integrated squared
error via an iterative plug-in procedure. ISJ tracks the true score distribution more
closely than closed-form rules, as illustrated in \Cref{fig:density-fit-comparison}.
closely than closed-form rules.
Because ISJ is iterative, it can fail to converge on small or degenerate batches early
in training. In those cases we fall back to Silverman's rule of
thumb~\cite{silverman1986density},