Crate sparseglm

Source
Expand description

Fast and modular coordinate descent solver for sparse generalized linear models

[sparseglm]’s philosophy consists in offering a highly flexible API. Any sparse GLM can be implemented in under 50 lines of code by providing its datafit term and its penalty term, which makes it very easy to support new estimators.

A quick example on how to solve a sparse GLM optimization problem by choosing an arbitrary combination of [Datafit] and [Penalty].

// Load some data and wrap them in a Dataset
let dataset = DatasetBase::from((x, y));

// Define a datafit (here a quadratic datafit for regression)
let mut datafit = Quadratic::new();

// Define a penalty (here a L1 penalty for Lasso)
let penalty = L1::new(0.7);

// Instantiate a Solver with default parameters
let solver = Solver::new();

// Solve the problem using coordinate descent
let coefficients = solver.solve(dataset, &mut datafit, &penalty).unwrap();

For widely-used models like Lasso, [sparseglm] already implements those models.

// Load some data and wrap them in a Dataset
let dataset = DatasetBase::from((x, y));

// Instantiate and fit the estimator
let estimator = Lasso::params()
                  .alpha(0.7)
                  .fit(&dataset)
                  .unwrap();

// Get the fitted coefficients
let coefficients = estimator.coefficients();

Modules§

datafits
datasets
estimators
penalties
solvers
utils

Traits§

Float
Float point numbers