What are Perceptrons?

In essence, a perceptron is an artificial neuron and represents the simplest form of an artificial neural network. An artificial neuron is a mathematical function, taking in inputs and producing an output – based on the idea of the biological neurons. The perceptron is a supervised machine learning algorithm (part of the binary classifiers), taking a number of binary inputs and producing one binary output – binary outputs can always be only two outcomes, for instance either 1 or 0, True or False, Yes or No, and so on.

A perceptron consist of inputs, function, and an output. The following is a simple diagram of a perceptron.

A simplified diagram of a perceptron

Calculation of a Perceptron

There are five steps to calculating a perceptron:

  1. Setting up a threshold value
    The threshold is used for the final decision – if the outcome is under the threshold the perceptron returns 0, otherwise 1.
  2. Applying weights to the values
    The assignment of weights provides a numerical importance to the values – which input value have greater impact on the output.
  3. Multiplying all weights with the values
    This results to weighted values for all inputs.
  4. Adding all results
    The outcome of this step provides the weighted sum of all inputs and the outcome for the threshold comparison.
  5. Activating the function
    The basic function of a perceptron compares the result and the threshold value in order to produce a final outcome.

The following is a more complex diagram of a perceptron, including the calculation steps.

diagram of a perceptron

Example

The following is a simple example of a perceptron calculation.

Objective: recommend whether someone should dine in a particular restaurant.

The dataset contains six inputs:

  • Location – location of the restaurant (good or bad)
  • Reviews – reviews from a local rating website (positive or negative)
  • Service – service of the restaurant (good or bad)
  • Price – pricing of the food and drinks (affordable or expensive)
  • Entertainment – (yes or no)
  • Food – favourite type of food (cuisine) of the person dining (yes or no)

The table below display the values for the specific restaurant of this example.

Location1 (good)
Reviews1 (positive)
Service0 (bad)
Price1 (affordable)
Entertainment0 (no)
Food0 (no)

The five steps of calculating a perceptron algorithm.

  1. The threshold value is 2.0. Anything below 2.0 returns NO (not recommending the restaurant), and a result above 2.0 returns YES (recommending the restaurant).
    ______________________________
  2. Value weights represent how strongly would the specific value affect the final decision. The input weights are as follows:

    0.7 location
    0.5 reviews
    0.4 service
    0.7 price
    0.3 entertainment
    0.2 food
    ______________________________
  3. Multiplication of weights and values:

    0.7 x 1 = 0.7
    0.5 x 1 = 0.5
    0.4 x 0 = 0
    0.7 x 1 = 0.7
    0.3 x 0 = 0
    0.2 x 0 = 0
    ______________________________
  4. Summing results:

    0.7 + 0.5 + 0 + 0.7 + 0 + 0 = 1.9 (weighted sum)
    ______________________________
  5. The activation functions compares the weighted sum with the threshold:

    Weighted sum – 1.9
    Threshold – 2.0

    1.9 < 2.0

    The weighted sum is smaller than the threshold, therefore the perceptron’s outcome is NO – not recommending the restaurant.

Next: Intelligent Agents