1.1.3 Fitting from named columns🔗ℹ

A formula, written with ~, names the response and the predictors in one expression:

> (define named-fit (formula-fit (~ mpg (+ wt hp)) cars #:lambda 4.0))
> (coef named-fit)

'(("(Intercept)" . 23.92234052081157)

  ("wt" . -1.1909909148532365)

  ("hp" . 0.0))

> (equal? (predict named-fit cars) (predict penalized-fit cars))

#t

It is the lasso fit above, with its coefficients keyed by name. Formulas also build interactions, transforms and factors; #:family chooses among the six families, and formula-path and formula-cv fit a path and cross-validate one. See Formulas and named data.