1.2.4 Results
A fit returns a transparent struct. The fields follow one pattern across the families:
intercept —
a real, or a vector of one per class or response (multinomial-result-intercepts, mgaussian-result-intercepts). Cox results have none. As in R, the multinomial intercepts are centred to sum to zero; adding the same constant to each would not change any probability. coefficients —
a dense vector with one entry per predictor, on the original (unstandardized) scale; a predictor the penalty dropped is exactly 0.0. Multinomial and multi-response results hold a vector of such vectors, one per class or response. r-squared or dev-ratio —
the fraction of the null deviance explained. For the Gaussian families this is R². lambda —
the penalty the solver used. num-passes —
the number of coordinate-descent passes.
A result prints as a one-line summary: its family, λ, deviance ratio, and how many of the predictors have a nonzero coefficient. The fields are read with the struct’s accessors:
> (define fit (ridge X y #:lambda 0.1)) > fit #<glmnet:gaussian λ=0.1 dev=0.9619 nz=2/2>
> (elnet-result-r-squared fit) 0.9618813537709814
Because the structs are transparent, equal? compares them field by field and match destructures them:
> (require racket/match) > (match-define (elnet-result a0 beta _ _ _) fit) > (list a0 beta) '(1.2148264276558987 #(1.5916761644299766 -0.6843296627955713))