Papers
Topics
Authors
Recent
Search
2000 character limit reached

Post-Hoc Matrix Scaling

Updated 5 July 2026
  • Post-Hoc Matrix Scaling is a family of methods that decomposes matrices and classifier outputs into diagonal scale factors and a normalized core to preserve ratio invariants.
  • The techniques include diagonal equilibration, classwise multiplicative scaling, and full softmax recalibration to address numerical conditioning and calibration challenges.
  • Practical implementations use iterative Sinkhorn-Knopp algorithms and stochastic gradient updates to efficiently reduce condition numbers and avoid overfitting.

Post-hoc matrix scaling denotes a family of procedures that rescale an already existing matrix, data table, or fixed classifier output after the primary measurements or model have been produced. In the supplied literature, the term covers at least three distinct but related constructions: diagonal row/column rescaling of a matrix to equalize norms or isolate a scale-invariant representative, classwise multiplicative scaling of a pretrained classifier under prior shift, and multiclass logistic recalibration with a learned weight matrix acting on logits or log-probabilities (Robinson, 2019, Bradley et al., 2011, Wei et al., 2023, Berta et al., 5 Nov 2025). The shared motif is that the underlying object is held fixed and only a post-hoc scaling transformation is learned or computed.

1. Conceptual scope and formal patterns

A recurring formal pattern is the factorization of an object into scale factors and a normalized core. For a real m×nm\times n data matrix AA, projective decomposition seeks

A=DrSDc,A = D_r\,S\,D_c,

where Dr=diag(r1,,rm)D_r=\mathrm{diag}(r_1,\dots,r_m) and Dc=diag(c1,,cn)D_c=\mathrm{diag}(c_1,\dots,c_n) are diagonal matrices of positive row- and column-scale factors, and SS is an m×nm\times n scale-normalized matrix whose rows and columns each have unit root-mean-square (RMS) (Robinson, 2019). In numerical linear algebra, equilibration uses the same diagonal-scaling template,

A^=DrADc,\hat A = D_r A D_c,

but the normalization target is approximate equality of row- and column-$2$-norms rather than preservation of ratio structure (Bradley et al., 2011).

In post-hoc classification under prior shift, scaling is applied not to matrix entries directly but to a pretrained probability vector η^(x)Δm\hat\eta(x)\in\Delta_m. A nonnegative scaling vector AA0 defines

AA1

or equivalently a logit shift AA2 (Wei et al., 2023). In multiclass calibration, a more expressive post-hoc recalibrator applies a full softmax layer to centered log-probabilities,

AA3

with AA4, AA5, and AA6 (Berta et al., 5 Nov 2025).

These formulations are not interchangeable. Diagonal matrix scaling, classwise vector scaling, and full matrix scaling act on different objects and preserve different invariants. A plausible implication is that “matrix scaling” is best understood as a structural family of post-hoc rescaling methods rather than as a single algorithm.

2. Projective decomposition and scale-invariant normalization

Projective decomposition treats a data matrix as defining a relationship between information labeling rows and information labeling columns, and normalizes both organizations simultaneously rather than standardizing only one axis (Robinson, 2019). The canonical form AA7 is defined by unit RMS constraints on every row and every column: AA8 with RMS operators

AA9

The associated equivalence relation is “equivalent up to scale.” Two matrices A=DrSDc,A = D_r\,S\,D_c,0 and A=DrSDc,A = D_r\,S\,D_c,1 of the same size A=DrSDc,A = D_r\,S\,D_c,2 are equivalent up to scale if there exist strictly positive vectors A=DrSDc,A = D_r\,S\,D_c,3 and A=DrSDc,A = D_r\,S\,D_c,4 such that

A=DrSDc,A = D_r\,S\,D_c,5

equivalently A=DrSDc,A = D_r\,S\,D_c,6. The set of all decompositions A=DrSDc,A = D_r\,S\,D_c,7 with positive A=DrSDc,A = D_r\,S\,D_c,8 yields an equivalence class of matrices that differ only by row and column dilations, and A=DrSDc,A = D_r\,S\,D_c,9 is the canonical representative once the unit-RMS constraints are imposed (Robinson, 2019).

A central property is preservation of pairwise relative ratios. Writing Dr=diag(r1,,rm)D_r=\mathrm{diag}(r_1,\dots,r_m)0, one obtains, for any two distinct rows Dr=diag(r1,,rm)D_r=\mathrm{diag}(r_1,\dots,r_m)1 and two distinct columns Dr=diag(r1,,rm)D_r=\mathrm{diag}(r_1,\dots,r_m)2,

Dr=diag(r1,,rm)D_r=\mathrm{diag}(r_1,\dots,r_m)3

The source text states this in words as preservation of every within-row or within-column ratio in Dr=diag(r1,,rm)D_r=\mathrm{diag}(r_1,\dots,r_m)4, so that Dr=diag(r1,,rm)D_r=\mathrm{diag}(r_1,\dots,r_m)5 is “ratio-scale invariant” (Robinson, 2019). This distinguishes projective decomposition from z-transformation, which enforces zero mean and unit standard deviation down each column, does nothing to the rows, and alters ratio structure because it subtracts column means.

Computation proceeds by an iterative proportional-scaling algorithm of Sinkhorn-Knopp type adapted to Dr=diag(r1,,rm)D_r=\mathrm{diag}(r_1,\dots,r_m)6 norms. Starting from Dr=diag(r1,,rm)D_r=\mathrm{diag}(r_1,\dots,r_m)7, Dr=diag(r1,,rm)D_r=\mathrm{diag}(r_1,\dots,r_m)8, and Dr=diag(r1,,rm)D_r=\mathrm{diag}(r_1,\dots,r_m)9, one alternates row normalization and column normalization until the maximum deviations of row and column RMS values from Dc=diag(c1,,cn)D_c=\mathrm{diag}(c_1,\dots,c_n)0 fall below a tolerance. For sufficiently supported matrices, standard results adapted to Dc=diag(c1,,cn)D_c=\mathrm{diag}(c_1,\dots,c_n)1 guarantee existence of the limit and uniqueness up to the one-dimensional diagonal scale symmetry (Robinson, 2019).

3. Diagonal equilibration in numerical linear algebra

In numerical linear algebra, post-hoc matrix scaling usually means equilibration: finding diagonal matrices Dc=diag(c1,,cn)D_c=\mathrm{diag}(c_1,\dots,c_n)2 and Dc=diag(c1,,cn)D_c=\mathrm{diag}(c_1,\dots,c_n)3 so that the scaled matrix Dc=diag(c1,,cn)D_c=\mathrm{diag}(c_1,\dots,c_n)4 has row and column Dc=diag(c1,,cn)D_c=\mathrm{diag}(c_1,\dots,c_n)5-norms that are equal, or approximately equal (Bradley et al., 2011). For signed matrices, the problem is conveniently transferred to the nonnegative matrix

Dc=diag(c1,,cn)D_c=\mathrm{diag}(c_1,\dots,c_n)6

and one seeks positive vectors Dc=diag(c1,,cn)D_c=\mathrm{diag}(c_1,\dots,c_n)7, Dc=diag(c1,,cn)D_c=\mathrm{diag}(c_1,\dots,c_n)8 such that Dc=diag(c1,,cn)D_c=\mathrm{diag}(c_1,\dots,c_n)9 is doubly stochastic, where SS0 and SS1. Once these are found, one sets

SS2

The classical exact formulation is Sinkhorn-Knopp iteration. If SS3 has total support, the iteration

SS4

converges to the unique scalings up to a scalar; the resulting doubly stochastic matrix is unique (Bradley et al., 2011). For symmetric SS5, the iteration

SS6

produces a symmetric scaling vector.

The matrix-free contribution of Bradley and Murray is to approximate the required actions of SS7 and SS8 using only matrix-vector products with SS9 and m×nm\times n0. If m×nm\times n1 has iid zero-mean, unit-variance entries, then for fixed m×nm\times n2,

m×nm\times n3

entrywise, so m×nm\times n4 can be estimated by squaring the output of a single matrix-vector product rather than forming m×nm\times n5 explicitly (Bradley et al., 2011). The resulting nonsymmetric stochastic iteration uses two matrix-vector products per iteration, while the symmetric version uses one. Storage is m×nm\times n6, and the method can be applied when the matrix is available only through a fast operator.

The stated motivation is conditioning. Empirically and theoretically, equilibration often drives down the m×nm\times n7-norm condition number m×nm\times n8 relative to m×nm\times n9, thereby accelerating iterative solvers or improving numerical stability of factorizations. In the reported experiments on 700+ nonsymmetric and 400+ symmetric matrices, sizes up to A^=DrADc,\hat A = D_r A D_c,0, after only A^=DrADc,\hat A = D_r A D_c,1 iterations the ratio A^=DrADc,\hat A = D_r A D_c,2 falls to A^=DrADc,\hat A = D_r A D_c,3–A^=DrADc,\hat A = D_r A D_c,4, nearly indistinguishable from exact equilibration, and A^=DrADc,\hat A = D_r A D_c,5 is reduced almost as much as with exact Sinkhorn-Knopp or classic binormalization (Bradley et al., 2011).

4. Distributionally robust post-hoc class scaling under prior shift

For fixed pretrained classifiers, post-hoc scaling can be used to address changes in class-prior or group-prior distributions. The DROPS procedure introduces a nonnegative scaling vector A^=DrADc,\hat A = D_r A D_c,6, one factor per class, and defines the post-scaled scorer

A^=DrADc,\hat A = D_r A D_c,7

equivalently

A^=DrADc,\hat A = D_r A D_c,8

A common parameterization is A^=DrADc,\hat A = D_r A D_c,9, where $2$0 and $2$1 is the empirical class-prior on a held-out validation set (Wei et al., 2023).

The optimization target is a distributionally robust loss around a chosen target prior $2$2. Let $2$3 denote the average loss on class $2$4. Then

$2$5

where $2$6 is a convex divergence on the simplex and $2$7 determines the size of the neighborhood around $2$8 (Wei et al., 2023). The paper states that $2$9 recovers pure average-class risk, η^(x)Δm\hat\eta(x)\in\Delta_m0 recovers true worst-class risk, and intermediate η^(x)Δm\hat\eta(x)\in\Delta_m1 values trade off average versus worst performance.

Theorem 3.1 identifies the Bayes-optimal form of the scorer for proper convex losses: η^(x)Δm\hat\eta(x)\in\Delta_m2 This justifies post-hoc classwise scaling as the relevant solution class. On a validation set, the algorithm alternates a projected η^(x)Δm\hat\eta(x)\in\Delta_m3-update, an exponentiated-gradient ascent step for η^(x)Δm\hat\eta(x)\in\Delta_m4, and a closed-form scaling update for η^(x)Δm\hat\eta(x)\in\Delta_m5; in the common case η^(x)Δm\hat\eta(x)\in\Delta_m6, the η^(x)Δm\hat\eta(x)\in\Delta_m7-update has a closed form (Wei et al., 2023).

Theorem 4.1 gives a post-hoc convergence guarantee. Under Lipschitz and convexity conditions, if the validation-set size satisfies η^(x)Δm\hat\eta(x)\in\Delta_m8 and one runs η^(x)Δm\hat\eta(x)\in\Delta_m9 steps with suitable learning rates, then with probability at least AA00 the returned averaged scorer AA01 satisfies

AA02

where AA03 is the class of all scalings of AA04 (Wei et al., 2023). The reported practical consequence is that once AA05 is fixed, deployment requires only adding AA06 to logits or multiplying probabilities by AA07 and renormalizing; no retraining or expensive computation is required at inference time beyond one vector addition per example.

5. Multiclass calibration via full and structured matrix scaling

In multiclass calibration, “matrix scaling” usually means a multinomial logistic recalibrator acting on a classifier’s log-probabilities. Given a black-box classifier AA08 producing AA09, one defines centered log-probabilities

AA10

and fits

AA11

with AA12 and AA13 (Berta et al., 5 Nov 2025). The centering step is required because softmax is invariant to adding the same scalar to every entry of its input. The paper motivates this construction by an idealized generative model in which logistic regression on the pre-softmax logits is well-specified, and notes that a quadratic term may arise but is often omitted in practice.

The central difficulty is parameter growth: a full AA14 matrix AA15 has AA16 parameters plus AA17 intercepts, which can overfit when AA18 is small. Structured Matrix Scaling (SMS) addresses this by decomposing AA19 into disjoint parameter groups,

AA20

where AA21 is a global scalar, AA22 is a diagonal deviation vector, and AA23 supplies off-diagonal terms (Berta et al., 5 Nov 2025). The fitting objective is a single convex problem combining multiclass log-loss with penalties on AA24, AA25, and AA26, scaled by group size and calibration-set size. In the special case AA27, one recovers Structured Vector Scaling (SVS).

Optimization is performed with a composite stochastic gradient solver, SAGA, with proximal updates to handle AA28 or group-LASSO penalties. The implementation uses robust preprocessing: a standard temperature scaling fit with Laplace smoothing is first applied to the raw probabilities, then AA29 is clipped to AA30 (Berta et al., 5 Nov 2025). The default practical choices reported are norm order AA31, exponents AA32 and AA33, and group weights AA34.

The empirical evaluation includes 68 multiclass UCI-style datasets from TabRepo, 7 base learners, and AA35 train/test folds AA36 AA37-fold CV for calibration, giving approximately 1400 experiments. Metrics are log-loss and Brier score on held-out test folds. SMS and SVS are reported to never overfit even on high-parameter regimes; standard unregularized matrix scaling often increases test loss on approximately AA38 of datasets; SMS yields strictly better median log-loss and Brier improvements than all baselines; and fitting time is approximately comparable to torchcal Vector/Matrix and AA39 faster than Dirichlet because the latter requires expensive cross-validated grid search (Berta et al., 5 Nov 2025). On CIFAR-10, CIFAR-100, and ImageNet benchmarks, SMS gives the largest absolute log-loss gains in nearly all cases, while unregularized matrix scaling catastrophically overfits on CIFAR-100.

6. Comparative properties, limitations, and recurrent points of confusion

One recurrent source of confusion is that post-hoc matrix scaling does not denote a single invariant-preserving operation. In projective decomposition, the salient invariant is the family of pairwise relative ratios, and the method is presented as appropriate for ratio-scale data in which zero has absolute meaning and comparisons are by division (Robinson, 2019). In equilibration, the target is approximate equality of row and column AA40-norms, with the primary benefit a reduction in AA41 and improved numerical behavior of iterative or direct solvers (Bradley et al., 2011). In post-hoc classification, the target is either robustness to a AA42-ball of prior shifts around a specified prior AA43 or improved probability calibration on a held-out set (Wei et al., 2023, Berta et al., 5 Nov 2025).

A second point is symmetry. Projective decomposition is explicitly symmetric in rows and columns and is invariant under transposition; applying it to AA44 or AA45 yields transposes of the same canonical form and the same scaling vectors (Robinson, 2019). Columnwise z-transformation is not symmetric: it standardizes columns, does nothing to rows, and alters ratios through centering. In classifier calibration, by contrast, the symmetry issue is not between rows and columns of a matrix but between classes: vector scaling treats classes independently through one factor per class, whereas full matrix scaling allows cross-class couplings through off-diagonal terms in AA46 (Wei et al., 2023, Berta et al., 5 Nov 2025).

A third point is feasibility and regularity. For AA47-adapted Sinkhorn-type normalization in projective decomposition, convergence is guaranteed for non-too-sparse matrices; in practice, any matrix where each row and column has at least one nonzero is fine (Robinson, 2019). Exact Sinkhorn-Knopp equilibration requires total support for scalability, and with support but not total support one may still observe partial equilibration (Bradley et al., 2011). DROPS requires a held-out validation set and states that the validation set must be approximately balanced across classes or groups so that AA48 and AA49 are reliable (Wei et al., 2023). Structured matrix scaling emphasizes the calibration-set-size regime explicitly: if AA50, SMS is expected to collapse toward temperature or vector scaling, and for very large AA51, such as ImageNet with AA52, the recommendation is to use SVS or TS unless thousands of calibration examples are available (Berta et al., 5 Nov 2025).

A plausible synthesis is that post-hoc matrix scaling is best viewed as a controlled manipulation of scale degrees of freedom after model fitting or data acquisition. What varies across subfields is the object being rescaled, the invariants one intends to preserve, and the statistical or numerical criterion used to choose the scaling.

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Post-Hoc Matrix Scaling.