On this page:
glmnet:   lasso and elastic-net regularized models
9.2

glmnet: lasso and elastic-net regularized models🔗ℹ

 (require glmnet) package: glmnet

These are Racket bindings to glmnet, the Friedman/Hastie/Tibshirani coordinate-descent solver for lasso and elastic-net regularized generalized linear models. The numerics come from the original, self-contained glmnet Fortran (vendored as "fortran/vendor/glmnet5.f90"); a small iso_c_binding shim exports a clean C ABI that this package binds to through Racket’s FFI.

The library is developed example-first: every model below ships as a runnable literate program under "glmnet/examples/" that is also woven into Examples. The four core models — ordinary least squares, ridge, lasso, and elastic net — are all a single call to the same elastic-net routine with different values of the mixing parameter α and the penalty λ.

License. Because this package vendors and links the GPL-2.0 glmnet Fortran, it is distributed under GPL-2.0-or-later unlike the permissively licensed bindings in the same family.

    1 Getting started

      1.1 Installation

      1.2 A first call

    2 User guide

      2.1 The elastic-net model

      2.2 Fitting a model

      2.3 Standardization and intercept

      2.4 Classification: the binomial family

      2.5 Multiclass classification: the multinomial family

      2.6 Survival analysis: the Cox family

      2.7 Count data: the Poisson family

      2.8 Multiple responses: the multi-response Gaussian family

      2.9 The precision contract

      2.10 Rebuilding the native library

    3 Examples

      3.1 Ordinary least squares (λ = 0)

      3.2 Ridge regression (L2, α = 0)

      3.3 Lasso (L1, α = 1)

      3.4 Elastic net (0 < α < 1)

      3.5 Binomial logistic regression (classification)

      3.6 Multinomial classification (K classes)

      3.7 Cox proportional hazards (survival)

      3.8 Poisson regression (counts)

      3.9 Multi-response Gaussian (grouped)

    4 API reference

      4.1 Fitting Gaussian models

      4.2 Fitting binomial (logistic) models

      4.3 Fitting multinomial (multiclass) models

      4.4 Fitting Cox proportional-hazards models

      4.5 Fitting Poisson (count) models

      4.6 Fitting multi-response Gaussian models

      4.7 Connectivity and self-checks