Distribution 1.0
12 July 2015

Massih R. Amini

Université Grenoble Alpes
Laboratoire d'Informatique de Grenoble



This program is an implementation of the Perceptron algorithm proposed by [Rosenblatt, 1957; Rosenblatt, 1958] and described in [Amini, 2015; p.64-69]. The algorithm is a supervised learning model developed to train binary linear classifiers. The implementation follows the widely used online learning scheme where training examples are randomly chosen one at a time and the model's weight vector is updated based on the prediction error made by the current classifier. Consider the form of the linear classifier as , where , , and , then the pseudo-code of the algorithm is:

Download and Installation

The program is free for scientific use only and it is developed on Linux with gcc and the source code is available from:

After downloading the file, and unpackting it:

> bzip2 -cd perceptron.tar.bz2 | tar xvf -

you need to compile the program in the new directory perceptron/

> make

After compilation, two executables are created:

  • perceptron-learn (for training the model)
  • perceptron-test (for testing it)

Training and testing

Each example in these files is represented by its class label (+1 or -1) followed by its plain vector representation. In perceptron/example/ there are four (training_set and test_set) files, from UCI repository.

Train the model:
> perceptron-learn [options] input_file parameter_file

Options are:
-t   (integer) Maximum number iterations (default 5000),
-a   (float) Learning rate (default 0.1),
-? Help

Test the model:
> perceptron-test input_file parameter_file

> ./perceptron-learn example/HEART-Train Parms-P-HEART
Training file contains 162 examples in dimension 13
Precision:1.000000 Recall:0.517647 F1-measure:0.682171 Error=0.253086
> ./perceptron-test example/HEART-Test Parms-P-HEART
Precision:0.902439 Recall:0.569231 F1-measure:0.698113 Errorr=0.296296


This program is publicly available for research use only. It should not be distributed for commercial use and the author is not responsible for any (mis)use of this algorithm.


[Amini, 2015] Massih-Reza Amini. Apprentissage Machine: de la théorie à la pratique. Eyrolles, 2015.

[Rosenblatt, 1957] Frank Rosenblatt. The Perceptron--a perceiving and recognizing automaton. Report 85-460-1, Cornell Aeronautical Laboratory, 1957.

[Rosenblatt, 1958] Frank Rosenblatt. The perceptron : A probabilistic model for information storage and organization in the brain. Psychological Review, 65 :386--408, 1958.