---
name: "mlpack_linear_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_linear_regression"
---

# mlpack\_linear\_regression(1)

simple linear regression and prediction

## NAME

**mlpack\_linear\_regression** - simple linear regression and prediction

## SYNOPSIS

```
 mlpack_linear_regression [-m unknown] [-l double] [-T unknown] [-t unknown] [-r unknown] [-V bool] [-M unknown] [-o unknown] [-h -v]
```

## DESCRIPTION

An implementation of simple linear regression and simple ridge regression using ordinary least squares. This solves the problem

```
  y = X * b + e
```

where X (specified by '**--training\_file** (**-t**)') and y (specified either as the last column of the input matrix '**--training\_file** (**-t**)' or via the ’**--training\_responses\_file** (**-r**)' parameter) are known and b is the desired variable. If the covariance matrix (X'X) is not invertible, or if the solution is overdetermined, then specify a Tikhonov regularization constant (with '**--lambda** (**-l**)') greater than 0, which will regularize the covariance matrix to make it invertible. The calculated b may be saved with the ’**--output\_predictions\_file** (**-o**)' output parameter.

Optionally, the calculated value of b is used to predict the responses for another matrix X' (specified by the '**--test\_file** (**-T**)' parameter):

```
   y' = X' * b
```

and the predicted responses y' may be saved with the ’**--output\_predictions\_file** (**-o**)' output parameter. This type of regression is related to least-angle regression, which mlpack implements as the 'lars' program.

For example, to run a linear regression on the dataset 'X.csv' with responses ’y.csv', saving the trained model to 'lr\_model.bin', the following command could be used:

$ **mlpack\_linear\_regression** **--training\_file** X.csv **--training\_responses\_file** y.csv **--output\_model\_file** lr\_model.bin

Then, to use 'lr\_model.bin' to predict responses for a test set 'X\_test.csv', saving the predictions to 'X\_test\_responses.csv', the following command could be used:

$ **mlpack\_linear\_regression** **--input\_model\_file** lr\_model.bin **--test\_file** X\_test.csv **--output\_predictions\_file** X\_test\_responses.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*\]**

  Existing LinearRegression model to use.

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

  Tikhonov regularization for ridge regression.  If 0, the method reduces to linear regression.  Default value 0.

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

  Matrix containing X' (test regressors).

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

  Matrix containing training set X (regressors).

- **--training\_responses\_file (-r) \[*unknown*\]**

  Optional vector containing y (responses). If not given, the responses are assumed to be the last row of the input file.

- **--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*\]**

  Output LinearRegression model.

- **--output\_predictions\_file (-o) \[*unknown*\]**

  If **--test\_file** is specified, this matrix is where the predicted responses will be saved.

## 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.
