If you are just getting started with ML, Perceptron is the best place to start. Perceptron is an algorithm for supervised learning of binary classifiers and the simplest model of forward neural network. It is the base of ML, and used in many areas of everyday life.

Sigmoid is an activation function used to map any input into value between 0 and 1 to add non-linearity to our neural network

Role of bias, is that we want to able to shift entire sigmoid curve along (x axis) to the left or to the right, to get better fit.

1) We start with the simple constructor of our class:

2) "calc": we get the sum of each input * corresponding weight,

then add treshold * last weight and pass into sigmoid (to get val. between 0 and 1)

then add treshold * last weight and pass into sigmoid (to get val. between 0 and 1)

Fill weights array with random numbers and add bias (1) to the end. In this case we are working with array of the length 2

3) we push the { input, target } into "data" array

in

(we use bias (1) if the index is equal to the length of our inputs

calculating how wrong we were

5) we call "retrain" which uses "data" to get previous guess,

"retrain" gets called "train" 1000 times by "learn()"

"retrain" gets called "train" 1000 times by "learn()"

6) usage

Code Editor

Powered by
Create your own unique website with customizable templates.