Docs · Machine learning

enet: elastic net regression.

Linear regression with a mixed L1 and L2 penalty, the equivalent of Spark MLlib's LinearRegression with regParam and elasticNetParam.

Module
ml_enet
Header
clio_ml/elastic_net.h

What it does

Linear regression with a mixed L1 and L2 penalty, the equivalent of Spark MLlib's LinearRegression with regParam and elasticNetParam. alpha 1 gives the Lasso and 0 gives ridge regression. Each step is one paged pass; the objective is recorded per step.

Rows

Features, then the label. clio_ml.COLUMNS["enet"] is 1.

Python

python
import numpy as np, clio_ml as cm
r = cm.fit_enet(X, alpha=0.5, iters=300)       # X: features | label
print(r.coef)
  • fit_enet(X, **options) accepts an in-memory array or a paged Dataset from cm.dataset(X) or cm.assimilate(...).
  • Options: lambda (0.01, regParam), alpha (1.0, elasticNetParam), step (0.9, assumes features scaled to [-1, 1]), iters (300), threads (256).
  • Result ElasticNetResult: coef (n_features coefficients, then the intercept), objective (per step), stats.

C++

cpp
ElasticNetResult FitElasticNet(Dataset &ds, const ElasticNetOptions &opt);
ElasticNetResult FitElasticNetPlain(const float *data, u64 n_rows, u32 nf,
                                    u64 elems_per_page, u32 nblocks,
                                    const ElasticNetOptions &opt);

The paged call needs the runtime; the Plain call runs the same kernel over a plain copy of the data without one.

Related: linear regression, logistic regression. Back to the machine learning overview.