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

# mlpack\_perceptron(1)

perceptron

## NAME

**mlpack\_perceptron** - perceptron

## SYNOPSIS

```
 mlpack_perceptron [-m unknown] [-l unknown] [-n int] [-T unknown] [-t unknown] [-V bool] [-M unknown] [-P unknown] [-h -v]
```

## DESCRIPTION

This program implements a perceptron, which is a single level neural network. The perceptron makes its predictions based on a linear predictor function combining a set of weights with the feature vector. The perceptron learning rule is able to converge, given enough iterations (specified using the ’**--max\_iterations** (**-n**)' parameter), if the data supplied is linearly separable. The perceptron is parameterized by a matrix of weight vectors that denote the numerical weights of the neural network.

This program allows loading a perceptron from a model (via the ’**--input\_model\_file** (**-m**)' parameter) or training a perceptron given training data (via the '**--training\_file** (**-t**)' parameter), or both those things at once. In addition, this program allows classification on a test dataset (via the ’**--test\_file** (**-T**)' parameter) and the classification results on the test set may be saved with the '**--predictions\_file** (**-P**)' output parameter. The perceptron model may be saved with the '**--output\_model\_file** (**-M**)' output parameter.

The training data given with the '**--training\_file** (**-t**)' option may have class labels as its last dimension (so, if the training data is in CSV format, labels should be the last column). Alternately, the '**--labels\_file** (**-l**)' parameter may be used to specify a separate matrix of labels.

All these options make it easy to train a perceptron, and then re-use that perceptron for later classification. The invocation below trains a perceptron on 'training\_data.csv' with labels 'training\_labels.csv', and saves the model to 'perceptron\_model.bin'.

$ **mlpack\_perceptron** **--training\_file** training\_data.csv **--labels\_file** training\_labels.csv **--output\_model\_file** perceptron\_model.bin

Then, this model can be re-used for classification on the test data ’test\_data.csv'. The example below does precisely that, saving the predicted classes to 'predictions.csv'.

$ **mlpack\_perceptron** **--input\_model\_file** perceptron\_model.bin **--test\_file** test\_data.csv **--predictions\_file** predictions.csv

Note that all of the options may be specified at once: predictions may be calculated right after training a model, and model training can occur even if an existing perceptron model is passed with the '**--input\_model\_file** (**-m**)' parameter. However, note that the number of classes and the dimensionality of all data must match. So you cannot pass a perceptron model trained on 2 classes and then re-train with a 4-class dataset. Similarly, attempting classification on a 3-dimensional dataset with a perceptron that has been trained on 8 dimensions will cause an error.

## OPTIONAL INPUT OPTIONS

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

  Default help info.

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

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

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

  Input perceptron model.  **--labels\_file** (**-l**) \[*unknown*\] A matrix containing labels for the training set.

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

  The maximum number of iterations the perceptron is to be run Default value 1000.

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

  A matrix containing the test set.

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

  A matrix containing the training set.

- **--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 for trained perceptron model.

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

  The matrix in which the predicted labels for the test set will be written.

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