Fit multinomial logistic regression with a minorize-maximize (MM) algorithm that uses a fixed curvature matrix instead of the Hessian.
Model: p(y=c∣x)=softmax(Wx)c with weights W of shape (C, D). To make the parameters identifiable, clamp the last class: wC=0 throughout, so only the first C−1 rows are learned.
Implement fit_softmax_mm(X, y, C, n_iter):
X: (N, D) features (include a ones column yourself if you want a bias); y: integer labels 0,…,C−1.
- Log-likelihood ℓ(W)=∑n[wyn⊤xn−log∑cexp(wc⊤xn)]; its gradient with respect to row c is gc=∑n(ync−μnc)xn (one-hot ync).
- Bohning's bound: for the C−1 free rows the Hessian satisfies H⪰B=−21[IC−1−C111⊤]⊗X⊤X (rows stacked class by class). Starting from W=0, iterate niter times
vec(W1:C−1)←vec(W1:C−1)−B−1vec(G1:C−1)
- Return
(W, history): the full (C, D) matrix (last row zeros) and the list of ℓ(W) values after each update (length n_iter).
B never changes, so compute whatever you need from it once, before the loop.