This document discusses machine learning classification using a single layer feed forward neural network. It begins with definitions of machine learning and the different types of machine learning problems. Supervised learning classification is explained where the goal is to learn from labeled training data to classify new observations. Common classification algorithms and the components of a learning model are described. Finally, the document provides an example of how a single layer perceptron neural network can be used to classify a sample dataset into two classes by learning the optimal weights through an iterative process.
3. What is machine learning?
ο±Definition of Machine Learning from WhatIS.com
βis a type of artificial intelligence (AI) that allows software
applications to become more accurate in predicting outcomes
without being explicitly programmedβ.
ο±Definition of Machine Learning from dictionary.com
βThe ability of a machine to improve its performance based on previous
results.β
Feed Forward Neural Network
3
5. Supervised Learning βClassificationβ
οIn machine learning and statistics, classification is a supervised
learning approach in which the computer program learns from the
data input given to it and then uses this learning to classify new
observation.
?
Feed Forward Neural Network
5
7. Components of learning
β’ Example:-Suppose that you are a bank manger and you want to
predict your customers behavior in the future according to their
historical data in order to make a credit card for money withdrawing
or not (approve it or deny).
23 years
Age
Male
Gender
$30,000
Annual Salary
1 Year
Years in residence
1 Year
Years in job
$ 15,000
Current debt
Sample of data vector
Feed Forward Neural Network
7
8. Components of learning cont.
β’ Formalization:-
β’ Input : x (vector of data βCustomer Applicationβ).
β’ Output : y (good/bad customer).
β’ Target Function : π: π β π (ideal credit approval formula).
βit is unknown function as if it known we donβt need to learn the machine and just go
ahead and implement our algorithmβ.
β’ Data : ππ, ππ , ππ, ππ , β¦ ππ, ππ (Historical data)
β’ Hypothesis: g: π β π
β’ we will use the historical data above in order to get the hypothesis which is the formal
name we are going to call the formula we get.
Feed Forward Neural Network
8
9. Components of learning cont.
ideal credit approval formula
Historical records of credit customers
Learning
Algorithm
Unknown target function
π: π β π
Training Example
ππ, ππ , ππ, ππ , β¦ ππ, ππ
Final Hypothesis
π β π
Hypothesis Set
π―
Set of candidate formula
Final credit Approval formula
Both of them are
called βLearning
Modelβ
Feed Forward Neural Network
9
10. β’ For input πΏ = (ππ, ππ, ππ , β¦ , ππ) βAttributes of the customerβ
Approve credit if π=π
π
wixi > ππππππππ
Deny credit if π=π
π
wixi < ππππππππ
So β π₯ = π πππ(( π=π
π
wixi )- threshold))
A simple hypothesis βThe perceptronβ
Feed Forward Neural Network
10
11. A simple hypothesis βThe perceptronβ
cont.
β’ β π₯ = π πππ(( π=π
π
wixi )- threshold))
β’ β π₯ = π πππ(( π=π
π
wixi ) + w0 ))
β’ β π₯ = π πππ( π=π
π
wixi )
Why W0 in order to get the following formula
by introducing an artificial coordinate
or vector called the bias x0=1
Feed Forward Neural Network
11
12. Neural Network βsingle layer perceptronβ
β’ is a system that is based on the biological neural
network, such as the brain. The brain has
approximately 100 billion neurons, which
communicate through electro-chemical signals.
β’ Each neuron receives thousands of connections
with other neurons, constantly receiving
incoming signals to reach the cell body.
β’ If the resulting sum of the signals surpasses a
certain threshold, a response is sent through the
axon.
Feed Forward Neural Network
12
13. Neural Network βsingle layer
perceptronβcont.
β’ is comprised of a network of artificial neurons (also known as
"nodes").
β’ These nodes are connected to each other, and the strength of their
connections to one another is assigned a value based on their
strength: inhibition (maximum being -1.0 week connection) or
excitation (maximum being +1.0 strong connection) we call them
weights.
β’ Three types of nodes:
β’ Input nodes.
β’ Hidden nodes.
β’ Output nodes.
Feed Forward Neural Network
13
14. Neural Network βsingle layer
perceptronβcont.
β’ There are two types of neural network:
1. Single layer neural network βPerceptronβ.
2. Multilayer neural network.
Feed Forward Neural Network
14
15. Neural Network βsingle layer
perceptronβcont.
οΆAlgorithm steps:
1. Start with the first sample.(Note: initial weights = 0)
2. Calculate Net = π=π
π
wixi .
EX:- Net = w1x1 + w2x2 + w0x0
Where x0 is a feature vector used to reduce number of iterations to get the optimal
line that used to separate the data it is called βBiasβ its initial value =1.
3. Calculate f(Net) : which is called :
1. Transfer function. 2. Activation function.
Ex :- F(Net) =
1 πππ‘ β₯ 0
0 πππ‘ < 0
4. If Output = Desired then go to next sample.
else Output β Desired Update weights then go to next sample.
5. Terminate step: find weights correct to all samples:
βwi= Ξ· * ( Desired β Output) * xi
βw = New weight - Old weight
New Weight = βw + Old Weight
Ξ· is called learning rate
βEtaβ used also to reduce
number of iterations
especially during weights
updating initially = 1
Feed Forward Neural Network
15
16. Example :Single Layer Perceptron
β’ Consider the following training data set:
1. Is the problem solvably ?Why?!
2. If it is solvable find weights using
perceptron single layer? Given :
F(Net) =
1 πππ‘ > 0
β1 πππ‘ β€ 0
1. Classify the following samples:
1. (-2.0) .
2. (1,1).
3. (0,1).
4. (-1,-2).
Desired
x2
X1
x0
1
1
-1
1
-1
1
0
1
1
-1
-1
1
-1
-1
0
1
Ξ·=1
Feed Forward Neural Network
16
17. Example :Single Layer Perceptron cont.
Solution
1. The problem can be solved because it has only two classes (1, -1) ,so it can be solved
using single layer perceptron.
2. The problem can be solved using tow ways:
1. Using Graph :
Represent the data set points on x and y
and find separable line between those two classes.
π¦βy1
π₯βx1
=
y2βy1
x2βx1
ο¨
π¦β 1
π₯+0.5
=
β1β1
β0.5+0.5
π¦β 1
π₯+0.5
=
β2
0
ο¨ -2x-1 = 0y ο¨ -2 x - 0y - 1 =0
w1x1 + w2x2 + w0x0
so w1 =-2 , w2 =0 , w0 =-1
-1
-2
1
2
-1
-2
1 2
(-0.5,1)
(-0.5,-1)
(-0.5,1) (-0.5,-1)
(x2, y2)
(x1, y1)
Feed Forward Neural Network
17
18. Example :Single Layer Perceptron cont.
2. Using perceptron :
1. Take the first sample, and initialize all weights to zero:
2. Calculate Net = π=π
π
wixi = 0*1 + 0*-1 + 0*1 = 0
f(Net) = -1
3. while f(net) β desired so update weights and go to next sample
4. βw0= Ξ· * ( Desired β Output) * xi = 1*(1+1)*1 =2
w0new = βw0+ wold = 2 + 0 = 2
βw1= Ξ· * ( Desired β Output) * xi = 1*(1+1)*-1 =-2
w1new = βw1+ wold = -2 + 0 = -2
βw2= Ξ· * ( Desired β Output) * xi = 1*(1+1)*1 =2
w2new = βw2+ wold = 2 + 0 = 2 ο¨ go to next sample
W2 = 0
W1 = 0
W0 = 0
x2 = 1
x1 = -1
x0 = 1
y
x2
X1
x0
1
1
-1
1
-1
1
0
1
1
-1
-1
1
-1
-1
0
1
Feed Forward Neural Network
18
F(Net) =
1 πππ‘ > 0
β1 πππ‘ β€ 0
19. Example :Single Layer Perceptron cont.
1. Take the Second sample, and initialize all weights to zero:
2. Calculate Net = π=π
π
wixi = 2*1 + -2*0 + 2*1 = 4
f(Net) = 1
3. while f(net) β desired so update weights and go to next sample
4. βw0= Ξ· * ( Desired β Output) * xi = 1*(-1-1)*1 =-2
w0new = βw0+ wold = -2 + 2 = 0
βw1= Ξ· * ( Desired β Output) * xi = 1*(-1-1)*0 =0
w1new = βw1+ wold = 0 -2 = -2
βw2= Ξ· * ( Desired β Output) * xi = 1*(-1-1)*1 =-2
w2new = βw2+ wold = -2 +2 = 0 ο¨ go to next sample
W2 = 2
W1 = -2
W0 = 2
x2 = 1
x1 = 0
x0 = 1
y
x2
X1
x0
1
1
-1
1
-1
1
0
1
1
-1
-1
1
-1
-1
0
1
Feed Forward Neural Network
19
F(Net) =
1 πππ‘ > 0
β1 πππ‘ β€ 0
20. Example :Single Layer Perceptron cont.
1. Take the third sample, and initialize all weights to zero:
2. Calculate Net = π=π
π
wixi = 0*1 + -2*-1 + 0*-1 = 2
f(Net) = 1
3. while f(net) = desired so keep weights as they are and go to next sample
W2 = 0
W1 = -2
W0 = 0
x2 = -1
x1 = -1
x0 = 1
y
x2
X1
x0
1
1
-1
1
-1
1
0
1
1
-1
-1
1
-1
-1
0
1
Feed Forward Neural Network
20
F(Net) =
1 πππ‘ > 0
β1 πππ‘ β€ 0
21. Example :Single Layer Perceptron cont.
1. Take the fourth sample, and initialize all weights to zero:
2. Calculate Net = π=π
π
wixi = 0*1 + -2*0 + 0*-1 = 0
f(Net) = -1
3. while f(net) = desired so keep weights as they are and go to next sample
W2 = 0
W1 = -2
W0 = 0
x2 = -1
x1 = 0
x0 = 1
y
x2
X1
x0
1
1
-1
1
-1
1
0
1
1
-1
-1
1
-1
-1
0
1
Feed Forward Neural Network
21
F(Net) =
1 πππ‘ > 0
β1 πππ‘ β€ 0
22. Example :Single Layer Perceptron cont.
1. Back again to the first sample, and initialize all weights to zero:
2. Calculate Net = π=π
π
wixi = 0*1 + -2*-1 + 0*1 = 2
f(Net) = 1
3. while f(net) = desired so keep weights as they are and go to next sample
W2 = 0
W1 = -2
W0 = 0
x2 = 1
x1 = -1
x0 = 1
y
x2
X1
x0
1
1
-1
1
-1
1
0
1
1
-1
-1
1
-1
-1
0
1
Feed Forward Neural Network
22
F(Net) =
1 πππ‘ > 0
β1 πππ‘ β€ 0
23. Example :Single Layer Perceptron cont.
1. Back again to the first sample, and initialize all weights to zero:
2. Calculate Net = π=π
π
wixi = 0*1 + -2*0 + 0*1 = 0
f(Net) = -1
3. while f(net) = desired so keep weights as they are and go to next sample
so the weighs used for this set is
W2 = 0
W1 = -2
W0 = 0
x2 = 1
x1 = 0
x0 = 1
y
x2
X1
x0
1
1
-1
1
-1
1
0
1
1
-1
-1
1
-1
-1
0
1
W2 = 0
W1 = -2
W0 = 0
Feed Forward Neural Network
23
F(Net) =
1 πππ‘ > 0
β1 πππ‘ β€ 0
24. Example :Single Layer Perceptron cont.
3. (-2, 0) = π’=π
π§
wixi = 0*1 + -2*-2 + 0*0 = 4
f(Net) = 1 so it is classified as class 1
(1, 1) = π’=π
π§
wixi = 0*1 + 1*-2 + 1*0 = -2
f(Net) = 1 so it is classified as class -1
(0, 1) = π’=π
π§
wixi = 0*1 + 0*-2 + 0*1 = 0
f(Net) = 1 so it is classified as class -1
(-1, -2) = π’=π
π§
wixi = 0*1 + -2*-1 + 0*-2 = 2
f(Net) = 1 so it is classified as class 1
Feed Forward Neural Network
24
F(Net) =
1 πππ‘ > 0
β1 πππ‘ β€ 0