Post-Hoc Matrix Scaling
- 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 data matrix , projective decomposition seeks
where and are diagonal matrices of positive row- and column-scale factors, and is an 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,
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 . A nonnegative scaling vector 0 defines
1
or equivalently a logit shift 2 (Wei et al., 2023). In multiclass calibration, a more expressive post-hoc recalibrator applies a full softmax layer to centered log-probabilities,
3
with 4, 5, and 6 (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 7 is defined by unit RMS constraints on every row and every column: 8 with RMS operators
9
The associated equivalence relation is “equivalent up to scale.” Two matrices 0 and 1 of the same size 2 are equivalent up to scale if there exist strictly positive vectors 3 and 4 such that
5
equivalently 6. The set of all decompositions 7 with positive 8 yields an equivalence class of matrices that differ only by row and column dilations, and 9 is the canonical representative once the unit-RMS constraints are imposed (Robinson, 2019).
A central property is preservation of pairwise relative ratios. Writing 0, one obtains, for any two distinct rows 1 and two distinct columns 2,
3
The source text states this in words as preservation of every within-row or within-column ratio in 4, so that 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 6 norms. Starting from 7, 8, and 9, one alternates row normalization and column normalization until the maximum deviations of row and column RMS values from 0 fall below a tolerance. For sufficiently supported matrices, standard results adapted to 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 2 and 3 so that the scaled matrix 4 has row and column 5-norms that are equal, or approximately equal (Bradley et al., 2011). For signed matrices, the problem is conveniently transferred to the nonnegative matrix
6
and one seeks positive vectors 7, 8 such that 9 is doubly stochastic, where 0 and 1. Once these are found, one sets
2
The classical exact formulation is Sinkhorn-Knopp iteration. If 3 has total support, the iteration
4
converges to the unique scalings up to a scalar; the resulting doubly stochastic matrix is unique (Bradley et al., 2011). For symmetric 5, the iteration
6
produces a symmetric scaling vector.
The matrix-free contribution of Bradley and Murray is to approximate the required actions of 7 and 8 using only matrix-vector products with 9 and 0. If 1 has iid zero-mean, unit-variance entries, then for fixed 2,
3
entrywise, so 4 can be estimated by squaring the output of a single matrix-vector product rather than forming 5 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 6, 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 7-norm condition number 8 relative to 9, thereby accelerating iterative solvers or improving numerical stability of factorizations. In the reported experiments on 700+ nonsymmetric and 400+ symmetric matrices, sizes up to 0, after only 1 iterations the ratio 2 falls to 3–4, nearly indistinguishable from exact equilibration, and 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 6, one factor per class, and defines the post-scaled scorer
7
equivalently
8
A common parameterization is 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, 0 recovers true worst-class risk, and intermediate 1 values trade off average versus worst performance.
Theorem 3.1 identifies the Bayes-optimal form of the scorer for proper convex losses: 2 This justifies post-hoc classwise scaling as the relevant solution class. On a validation set, the algorithm alternates a projected 3-update, an exponentiated-gradient ascent step for 4, and a closed-form scaling update for 5; in the common case 6, the 7-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 8 and one runs 9 steps with suitable learning rates, then with probability at least 00 the returned averaged scorer 01 satisfies
02
where 03 is the class of all scalings of 04 (Wei et al., 2023). The reported practical consequence is that once 05 is fixed, deployment requires only adding 06 to logits or multiplying probabilities by 07 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 08 producing 09, one defines centered log-probabilities
10
and fits
11
with 12 and 13 (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 14 matrix 15 has 16 parameters plus 17 intercepts, which can overfit when 18 is small. Structured Matrix Scaling (SMS) addresses this by decomposing 19 into disjoint parameter groups,
20
where 21 is a global scalar, 22 is a diagonal deviation vector, and 23 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 24, 25, and 26, scaled by group size and calibration-set size. In the special case 27, one recovers Structured Vector Scaling (SVS).
Optimization is performed with a composite stochastic gradient solver, SAGA, with proximal updates to handle 28 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 29 is clipped to 30 (Berta et al., 5 Nov 2025). The default practical choices reported are norm order 31, exponents 32 and 33, and group weights 34.
The empirical evaluation includes 68 multiclass UCI-style datasets from TabRepo, 7 base learners, and 35 train/test folds 36 37-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 38 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 39 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 40-norms, with the primary benefit a reduction in 41 and improved numerical behavior of iterative or direct solvers (Bradley et al., 2011). In post-hoc classification, the target is either robustness to a 42-ball of prior shifts around a specified prior 43 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 44 or 45 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 46 (Wei et al., 2023, Berta et al., 5 Nov 2025).
A third point is feasibility and regularity. For 47-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 48 and 49 are reliable (Wei et al., 2023). Structured matrix scaling emphasizes the calibration-set-size regime explicitly: if 50, SMS is expected to collapse toward temperature or vector scaling, and for very large 51, such as ImageNet with 52, 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.