---
name: "mlpack_softmax_regression"
section: "1"
platform: "linux"
package: "mlpack-bin"
version: "4.6.0-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/mlpack_softmax_regression"
---

# mlpack\_softmax\_regression(1)

softmax regression

## NAME

**mlpack\_softmax\_regression** - softmax regression

## SYNOPSIS

```
 mlpack_softmax_regression [-m unknown] [-l unknown] [-r double] [-n int] [-N bool] [-c int] [-T unknown] [-L unknown] [-t unknown] [-V bool] [-M unknown] [-p unknown] [-P unknown] [-h -v]
```

## DESCRIPTION

This program performs softmax regression, a generalization of logistic regression to the multiclass case, and has support for L2 regularization. The program is able to train a model, load an existing model, and give predictions (and optionally their accuracy) for test data.

Training a softmax regression model is done by giving a file of training points with the '**--training\_file** (**-t**)' parameter and their corresponding labels with the '**--labels\_file** (**-l**)' parameter. The number of classes can be manually specified with the '**--number\_of\_classes** (**-c**)' parameter, and the maximum number of iterations of the L-BFGS optimizer can be specified with the ’**--max\_iterations** (**-n**)' parameter. The L2 regularization constant can be specified with the '**--lambda** (**-r**)' parameter and if an intercept term is not desired in the model, the '**--no\_intercept** (**-N**)' parameter can be specified.

The trained model can be saved with the '**--output\_model\_file** (**-M**)' output parameter. If training is not desired, but only testing is, a model can be loaded with the '**--input\_model\_file** (**-m**)' parameter. At the current time, a loaded model cannot be trained further, so specifying both '**--input\_model\_file** (**-m**)' and '**--training\_file** (**-t**)' is not allowed.

The program is also able to evaluate a model on test data. A test dataset can be specified with the '**--test\_file** (**-T**)' parameter. Class predictions can be saved with the '**--predictions\_file** (**-p**)' output parameter. If labels are specified for the test data with the '**--test\_labels\_file** (**-L**)' parameter, then the program will print the accuracy of the predictions on the given test set and its corresponding labels.

For example, to train a softmax regression model on the data 'dataset.csv' with labels 'labels.csv' with a maximum of 1000 iterations for training, saving the trained model to 'sr\_model.bin', the following command can be used:

$ **mlpack\_softmax\_regression** **--training\_file** dataset.csv **--labels\_file** labels.csv **--output\_model\_file** sr\_model.bin

Then, to use 'sr\_model.bin' to classify the test points in 'test\_points.csv', saving the output predictions to 'predictions.csv', the following command can be used:

$ **mlpack\_softmax\_regression** **--input\_model\_file** sr\_model.bin **--test\_file** test\_points.csv **--predictions\_file** predictions.csv

## OPTIONAL INPUT OPTIONS

- **--help (-h) \[*bool*\]**

  Default help info.

- **--info \[string\]**

  Print help on a specific option. Default value ''.

- **--input\_model\_file (-m) \[*unknown*\]**

  File containing existing model (parameters).  **--labels\_file** (**-l**) \[*unknown*\] A matrix containing labels (0 or 1) for the points in the training set (y). The labels must order as a row.

- **--lambda (-r) \[*double*\]**

  L2-regularization constant Default value 0.0001.

- **--max\_iterations (-n) \[*int*\]**

  Maximum number of iterations before termination. Default value 400.

- **--no\_intercept (-N) \[*bool*\]**

  Do not add the intercept term to the model.

- **--number\_of\_classes (-c) \[*int*\]**

  Number of classes for classification; if unspecified (or 0), the number of classes found in the labels will be used. Default value 0.

- **--test\_file (-T) \[*unknown*\]**

  Matrix containing test dataset.

- **--test\_labels\_file (-L) \[*unknown*\]**

  Matrix containing test labels.

- **--training\_file (-t) \[*unknown*\]**

  A matrix containing the training set (the matrix of predictors, X).

- **--verbose (-v) \[*bool*\]**

  Display informational messages and the full list of parameters and timers at the end of execution.

- **--version (-V) \[*bool*\]**

  Display the version of mlpack.

## OPTIONAL OUTPUT OPTIONS

- **--output\_model\_file (-M) \[*unknown*\]**

  File to save trained softmax regression model to.

- **--predictions\_file (-p) \[*unknown*\]**

  Matrix to save predictions for test dataset into.

- **--probabilities\_file (-P) \[*unknown*\]**

  Matrix to save class probabilities for test dataset into.

## ADDITIONAL INFORMATION

For further information, including relevant papers, citations, and theory, consult the documentation found at http://www.mlpack.org or included with your distribution of mlpack.
