A perceptron is the most simple type of neuronal network. It refers to a single-layer neural network meaning a network with just one neuron.

The perceptron term was first introduced by Frank Rosenblatt in 1957, and it is mainly used for binary classifications.

## How does a perceptron work

The perceptron is made of 5 key concepts.

- input values
- weights for inputs
- the net input function
- activation function
- output

So, let's say we want to use a perceptron to determine if a given point is red or blue based on the coordinates of that point. A point will be red if it's on the right side of a given line of blue if it's on the left side of that line.

In this case, we will have 2 inputs, the coordinates of the point. Each coordinate will have a given weight.

Initially, the weights will start from random values and will be later adjusted, via trial and error, to improve the accuracy of the results.

The net input function is determined by summing all the products between the weights and the inputs. This is alos known as the weighted sum:

`const netInput = input1*weight1 + input2*weight2 + ... `

Then this `netInput`

is given as a parameter to the activation function to determine the output:

`const output = activationFunction(netInput)`

The output will contain some type of encoding where, for example, if the output is smaller than 0 then the given point is red, and if the output is greater than 0 then the given point is blue.

Please note that because of how machine learning works, we will predict the result with a given probability.

## What types of problems are the perceptrons able to solve

The perceptron is a linear binary classifier. This means that it is best to use it when we want to determine if the data is of one type or another. Or, in other words, it can determine the line that separates two data categories.

However, with some mathematical tricks, we can also use perceptrons to determine circular data functions like the one in the image below.

Basically, we transpose the data from a cartesian coordinate system to polar coordinates. Checkout the beflow youtube video (from min 11.20):

Next, let's see how to code your first Javascript neuronal network from scratch.

#### ðŸ“– 50 Javascript, React and NextJs Projects

Learn by doing with this FREE ebook! Not sure what to build? Dive in with 50 projects with project briefs and wireframes! Choose from 8 project categories and get started right away.

#### ðŸ“– 50 Javascript, React and NextJs Projects

Learn by doing with this FREE ebook! Not sure what to build? Dive in with 50 projects with project briefs and wireframes! Choose from 8 project categories and get started right away.