Loading…
Loading…
Model incomplete observations with a projection mask, derive singular-value thresholding, and implement proximal gradient for nuclear-norm regularized completion.
A partially observed table contains two different kinds of information: measured values and locations where no value has been measured. Matrix completion uses relationships across rows and columns to estimate those missing values. A low-rank model expresses these relationships through a small number of shared latent factors. The same factors connect observed and unobserved entries, allowing information from one part of the table to influence another.
The missingness pattern is as important as the number of measurements. Three entries can determine a small rank-one table, while another observation pattern can leave many possible completions. We will first specify exactly which observations enter the loss, then use a convex singular-value penalty to encourage a simpler fitted matrix. The resulting algorithm combines a gradient step on observed residuals with singular-value thresholding across the whole matrix.
Let store the available data, and let record observed positions. Entries of outside are storage choices, not targets for the fit. An observed zero remains a measurement and belongs to .
Definition
The observation operator keeps precisely the observed coordinates:
For matrices of the same shape, the Frobenius inner product and norm are and . If the singular values of are , where , its nuclear norm is
The two norms summarize different aspects of the singular spectrum. The Frobenius norm measures total squared size, while the nuclear norm adds singular magnitudes. The rank instead counts positive singular values. Penalizing the nuclear norm can set singular values to zero through a thresholding step, without explicitly searching over discrete rank values.
Theorem
With the Frobenius inner product, is self-adjoint and idempotent. In particular,
Proof
Both and equal , proving self-adjointness. Applying the same mask twice changes nothing, proving idempotence. The observed and unobserved parts have disjoint support, so their inner product is zero. Pythagoras gives the norm identity and its inequality.
A rank-at-most- model can be written , where and . Entry is the inner product of row of and row of . These shared coordinates make a missing entry depend on the same factors that explain measured entries. Searching directly for the factors produces a nonconvex problem because they multiply each other.
The factors themselves are not uniquely named coordinates. For any invertible , replacing them by and leaves unchanged. Even the completed matrix may be undetermined by the observations. To discuss recovery, distinguish this coordinate freedom from whether the missing entries have a unique value. Low rank supplies a structural assumption; the observation pattern must still contain enough connections to determine the desired entries.
Worked example
Suppose the observed entries give
A rank-one completion requires , so uniquely. The completed matrix factors as .
If only the two diagonal entries are observed, all matrices
have rank one and match the observations. For instance, and give different missing values. A low-rank assumption alone cannot select which is the underlying table. A regularizer can express a preference among fits, but that preference does not add an observation.
For measurements that may contain noise, consider the objective
Only measured residuals enter . Replacing the unused entries of by other numbers does not change the objective. The nuclear penalty acts on the whole candidate matrix and connects its coordinates through singular directions. Both terms are convex, although the full objective need not be strictly convex for an incomplete observation pattern.
The parameter controls a fit-and-complexity compromise. Larger values place more weight on shrinking singular magnitudes, often removing more singular directions. The fitted observed entries can differ from the measurements. For exact measurements, the separate constrained model subject to expresses exact agreement. Here we develop the displayed penalized objective, whose observed residuals remain part of the optimization.
The nuclear norm is a convex matrix norm. One useful justification is its dual description as the largest inner product with a matrix of spectral norm at most one. The singular-value trace inequality bounds that inner product by the sum of singular values, and aligned singular directions attain the bound. A maximum of linear functions is convex. This connects the convexity of the penalty to the same singular-vector geometry used below.
Definition
For and , define
Theorem
For any fully specified matrix and , the unique minimizer of
is .
Proof
Let the ordered singular values of and be and . The von Neumann trace inequality states . Expanding the squared distance therefore bounds the objective below by
Each summand is minimized at . This operation preserves their order. Choosing the singular vectors of to align with those of makes the trace inequality an equality and attains every scalar minimum. The squared-distance term is strictly convex, so the minimizing matrix is unique, even when a choice of singular-vector basis is not unique.
This threshold subtracts the same amount from each positive singular value and sets singular values at or below the threshold to zero. A rank truncation instead keeps the largest selected singular values unchanged. Both can produce lower-rank matrices, but they solve different objectives. At a repeated singular value, a numerical SVD can return a different orthonormal basis for its subspace; applying the same scalar threshold throughout that subspace gives the same reconstructed matrix.
Worked example
Take and . Its singular directions are the coordinate axes, so the solution is . Its squared-distance contribution is , and its penalty is . The total objective is . Keeping unchanged gives objective , so exact data agreement is not the minimizer of this penalized problem. The threshold has shrunk both observed singular magnitudes.
The gradient of the observed loss is
The inequality follows from the projection theorem, so one is a Lipschitz constant for the gradient. A step size gives the update
For unit step size this becomes
The forward point uses measurements at observed positions and the current estimate elsewhere. Thresholding then acts on that entire matrix. The output can change observed entries as well as fill missing ones, consistently with the objective's balance between observed residual and nuclear penalty. The unobserved coordinates survive in the next forward point and influence the next SVD; they are not repeatedly treated as measured zeros.
To justify the step, expand the quadratic loss at with increment :
Adding the nuclear penalty creates a quadratic upper model equal to at . Its minimizer is the unit-step update, by the proximal theorem. Minimizing this upper model cannot increase . For a smaller step, replacing its quadratic coefficient by gives another valid upper model. The step-size restriction therefore comes directly from the mask's norm, rather than from an arbitrary tuning rule.
There is a useful scale for the regularization parameter. Put and write for its largest singular value. The trace inequality gives
Consequently, if the parameter is at least this largest singular value, zero is a global minimizer. This gives an exact explanation for an iteration that removes every singular direction. The parameter has assigned enough cost to matrix magnitude that any possible improvement in observed fit is outweighed. The threshold scale is computed from the observed table and its mask, not from an imagined fully observed matrix. It also supplies a useful endpoint when examining a sequence of parameter choices, with smaller parameters allowing increasingly substantial fitted structure.
The gradient alone does not describe optimality for a nonsmooth penalized objective. A subgradient of the nuclear norm at means that for every . The unit-step proximal update satisfies
If an update returns the same matrix, this supporting inequality balances the observed gradient against the penalty. Adding it to the ordinary first-order inequality for the convex function proves that every candidate matrix has objective at least the current one. A fixed point is therefore a global minimizer of the stated convex objective. Observed residuals may remain nonzero at this point because their gradient is balanced by a nuclear-norm subgradient.
This argument motivates checking the size of the proximal update as well as the objective. A small change tests approximate stationarity of the complete penalized problem. It does not require the observed residual gradient to vanish, nor does it establish how accurate unobserved predictions are.
Worked example
Use the three observed entries of the first example, store , initialize , and take . The missing upper-right position is excluded from . The forward point is , whose singular values are and . Both exceed one. Its orthogonal polar factor is
Thus the missing estimate becomes about , even though it was zero in the initial storage table. The observed estimates also move. The objective falls from to . The exact rank-one completion has missing value . The first penalized iteration gives an intermediate estimate under its fit-and-penalty criterion.
The Boolean mask records observation status independently of numeric values. The following implementation uses unit steps and the objective just derived.
import numpy as np
observed = np.array([[True, False], [True, True]])
P = np.array([[2., 0.], [3., 6.]])
lam = 1.
def svt(Y, threshold):
U, s, Vt = np.linalg.svd(Y, full_matrices=False)
return (U * np.maximum(s - threshold, 0.)) @ Vt
def objective(X):
residual = np.where(observed, X - P, 0.)
return 0.5 * np.sum(residual**2) + lam * np.linalg.svd(
X, compute_uv=False
).sum()
X = np.zeros_like(P)
first = svt(P, lam)
history = [objective(X)]
for _ in range(100):
gradient = np.where(observed, X - P, 0.)
X = svt(X - gradient, lam)
history.append(objective(X))
assert np.all(np.diff(history) <= 1e-10)
print(np.round(first, 6))
print(round(history[0], 6), round(history[-1], 6))
The first matrix printed is approximately . The objective values printed are and approximately . The finite iteration count gives a reproducible numerical example. For a larger application, report the objective and a measure of iterate change when deciding when to stop. A low fitting loss alone cannot measure accuracy at positions whose values were never supplied.
The numerical size of the parameter depends on how values and the loss are scaled. If all measurements are multiplied by a positive constant , scale the parameter by the same constant. For a candidate scaled in the same way, both the residual term and the penalty are then multiplied by , so the ordering of all candidate objectives is unchanged. This identifies how an equivalent model behaves after a change of measurement units, rather than assigning an absolute interpretation to one parameter value.
Similarly, replacing the summed observed squared loss by its average requires dividing the penalty coefficient by the number of observations to obtain the same optimizer. Keeping the coefficient unchanged while averaging the loss instead increases the penalty's relative influence. State the loss normalization before comparing parameter values across implementations or tables with different amounts of observed data.
To assess predictions, reserve some genuinely measured entries for validation and construct the fitting mask from the remaining entries. Evaluate predicted values on the held-out positions without including those positions in gradient steps. This measures predictions of observations not used for fitting. It also changes the fitting observation pattern, so the split should retain the row and column information needed by the intended model. Optimization diagnostics and prediction diagnostics answer distinct questions: one checks whether the selected objective has been minimized, while the other checks the usefulness of its resulting estimates.
Common mistake
An observed zero contributes its squared residual just like any other measurement. A missing entry contributes no residual, regardless of the number stored there. Construct the mask from observation status. Also keep the order of the derived update: make the gradient forward point, then apply singular-value thresholding. This preserves the stated penalized objective and its step-size argument.
The observation operator is an orthogonal projection, which determines both the loss and its gradient. Low-rank structure couples missing entries, while identifiability depends on where measurements occur. The nuclear norm gives a convex singular-value penalty, and its proximal map soft-thresholds the singular values. Combining that map with the observed gradient yields an algorithm whose unit step has a direct quadratic-upper-bound justification.
Checkpoint
Use the determinant and the observation definition.
Checkpoint
Compute both the squared residual term and the nuclear penalty.
Checkpoint
Compare the threshold with the larger displayed singular value.
The determinant is , so rank at most one forces . The second row is nonzero, so the completed table has rank one. Omitting would remove an actual equation and permit other rank-one completions. Its zero value does not make it missing.
The solution is , of rank one. Its squared-distance term is , and the penalty is . The minimized objective is .
The largest forward-point singular value is . Thresholding at seven gives the zero matrix for the first update. The model uses an observed-residual penalty, so it permits disagreement with measured entries; it does not impose their equality as a constraint.