Docs · Machine learning

mlr: multinomial logistic regression.

Softmax regression over up to 8 classes with an L2 penalty, the equivalent of Spark MLlib's LogisticRegression with family multinomial.

Module
ml_mlr
Header
clio_ml/multinomial_logistic.h

What it does

Softmax regression over up to 8 classes with an L2 penalty, the equivalent of Spark MLlib's LogisticRegression with family multinomial. It is optimised with L-BFGS; every objective and gradient evaluation is one paged pass.

Rows

Features, then the class label (0 to num_classes - 1). clio_ml.COLUMNS["mlr"] is 1.

Python

python
import numpy as np, clio_ml as cm
r = cm.fit_mlr(X, num_classes=4, iters=30)     # X: features | class
class_id = cm.predict("mlr", r, X[0, :-1])
  • fit_mlr(X, **options) accepts an in-memory array or a paged Dataset from cm.dataset(X) or cm.assimilate(...).
  • Options: num_classes (3, at most 8), l2 (0.001), iters (30 L-BFGS iterations), history (10), threads (256).
  • Result MultinomialLogisticResult: nf, C, coef (C rows of weights then bias), objective, grad_norm, evaluations (paged passes used), stats.

C++

cpp
MultinomialLogisticResult FitMultinomialLogistic(Dataset &ds,
                                                  const MultinomialLogisticOptions &opt);
u32 MultinomialLogisticPredict(const MultinomialLogisticResult &m, const float *x);

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

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