SlideShare a Scribd company logo
Data mining
Assignment week 5




BARRY KOLLEE

10349863
Assignment	
  5	
  
	
  
Exercise 1: Perceptrons

1.1 What is the function of the learning rate in the perceptron training rule?

Within our perceptrons we take a certain weight into account when calculating the difference between
the target and outcome values. This weight it’s purpose is to adjust the actual value which we compare
to a certain threshold (i.e. ‘do we play tennis; yes or no?’).

The learning rate it’s goal is to define the extend of this weight adjustment. This learning rate can be
described as a sensitivity for our calculation of the difference between the target and outcome value. In
conclusion we can state that we give a value to this learning rate based on the difference between the
target and outcome value.

1.2 What kind of Boolean functions can be modeled with perceptrons and which
Boolean functions can not be modeled and why?

Within the model of our perceptron we take several Boolean functions into account which we regularly
see within the common programming languages. These Boolean conditions are:
    •    AND (‘&&’)
    •    OR (‘||’)
    •    NAND (‘! &&’)
    •    NOR (‘! ||’)

The Boolean condition ‘XOR’ can’t be implemented within the perceptron it’s model. When using the
XOR Boolean function the output can only be 1 if x1 is not equal to x2 (x1 != x2)1. The XOR
Boolean condition can be represented by using combinations of perceptrons (more then 1-level) That’s
because we can express the XOR statement using an AND and an OR condition.




	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  
1
       Objective C representation of x1 not equal to x2



2
Assignment	
  5	
  
	
  

Exercise 2: Weight Updating in Perceptrons

Assume the following set of instances with the weights: w0 = 0.4 and w1 = 0.8. The threshold
is 0.

What are the output values for each instance
before the threshold function is applied? What is
the accuracy of the model when applying the
threshold function?

For calculating the output values of the instances we perform the following formula:



       Instance value   = w0 + (x1 * w1)

       Output value:

       1 if((w0 + (x1 * w1) +… +(xn * wn))) > 0
       -1 otherwise


With these formula’s we can find the output values of every instance within the table. If the result of the
instance value is higher then 0 the output value is 1. If this is not the case we set it to -1. Underneath are
all formula results and output values. They formula results are given in green and the output values are
in red.

Instance 1 :



       Instance 1 = 0.4 + (0.8 * 1.0)
       Instance 1 = 0.4 + 0.8
       Instance 1 = 1.2

       Instance 1 > threshold
       Output value for instance 1 = 1.0



Instance 2 :



       Instance 2 = 0.4 + (0.8 * 0.5)
       Instance 2 = 0.4 + 0.4
       Instance 2 = 0.8

       Instance 2 > threshold
       Output value for instance 2 = 1.0



Instance 3:



       Instance 3 = 0.4 + (0.8 * -0.8)
       Instance 3 = 0.4 - 0.64
       Instance 3 = -0.24

       Instance 3 < threshold
       Output value for instance 3 = -1.0




3
Assignment	
  5	
  
	
  

Instance 4:



       Instance 4 = 0.4 + (0.8 * 1.0) + (0.8 * -0.2)
       Instance 4 = 0.4 - 0.16
       Instance 4 = 0.24

       Instance 4 > threshold
       Output value for instance 4 = 1.0



If we compare these output values with the instance it’s      Instance   Target   Output
target value. We can state that we have a 75 % accuracy                  class    value
           th
because ¾ of the target classes is equal to it’s respective              value
output value.
                                                                 1         1        1
                                                                 2         1        1
                                                                 3         -1       -1
                                                                 4         -1       1




4
Assignment	
  5	
  
	
  

Exercise 3: Gradient Descent
Consider the data in Exercise 2. Apply the gradient descent algorithm and
compute the weight updates for one iteration. You can assume the same initial
weights, and threshold as in Exercise 2. Assume that the learning rate = 0.2.

To compute the weight update for one iteration we perform the following formula where:
    •  ‘n’ represents the learning rate
    •  ‘o’ represents the output value (from previous exercise) < 1.2 , 0.8, -0.24, 0.24 >
    •  ‘xi’ represents the input value

We calculate for every instance:


       for each wi (instance) {
           Δwi = n (t – 0) * xi
           Δwi = wi + Δwi
        }




Instance 1 (output is 1.2)


       Δw0 = Δw        + n   ( t2 – o2 ) * X0
       Δw0 = 0         + 0.2 ( 1 – 1.2) * 1.0
       Δw0 = -0.04

       Δw1 = Δw1   + n   ( t2 – o2 ) * X1
       Δw1 = 0     + 0.2 (1 – 1.2 ) * 1.0
       Δw1 = -0.04


Instance 2 (output is 0.8)


       Δw0 = Δw        + n   ( t2 – o2 ) * X0
       Δw0 = -0.04     + 0.2 ( 1 - 0.8) * 1
       Δw0 = 0

       Δw1 = Δw1       + n   ( t2 – o2 ) * X1
       Δw1 = -0.04     + 0.2 (1 – 0.8 ) * 0.5
       Δw1 = -0.02


Instance 3 (output 3 = -0.24)


       Δw0 = Δw        + n   ( t2   - o2      ) * X0
       Δw0 = 0         + 0.2 ( -1   - (-0.24) ) * 1
       Δw0 = 0         + 0.2 ( -1   + 0.24    ) * 1
       Δw0 = 0.152
       Δw1   =   Δw1    + n  ( t2   –   o2 ) * X1
       Δw1   =   -0.02 + 0.2 ( -1   –   (-0.24) ) * ( -0.8 )
       Δw1   =   -0.02 + 0.2 ( -1   +   0.24 ) * ( -0.8 )
       Δw1   =   0.1016


Instance 4 (output 4 = 0.24)


       Δw0 = Δw            + n   ( t2 – o2 ) * X0
       Δw0 = 0.152         + 0.2 ( -1 - 0.24 ) * 1
       Δw0 = -0.4

       Δw1 = Δw1           + n   ( t2 – o2 ) * X1
       Δw1 = -0.1016        + 0.2 ( -1 - 0.24 ) * -0.2
       Δw1 = 0.1016




5
Assignment	
  5	
  
	
  
Now we do our weight updating:


       W0 = W0 + ΔW0
       W0 = 0.4 + (-o.4)
       W0 = 0

       W1 = W1 + ΔW1
       W1 = 0.8 + 0.1512
       W1 = 0.9512



Now we could perform another iteration by starting all over again…




6
Assignment	
  5	
  
	
  


Exercise 4: Stochastic Gradient Descent
Consider the data in Exercise 2. Apply the stochastic
gradient descent algorithm and compute the weight
updates for one iteration. You can assume the same initial
weights, and threshold as in Exercise 2. Assume that the
learning rate = 0.2.

For applying a stochastistic gradient descent algorithm we use the following formula where:
    •    Threshold (‘t’) = 0
    •    Learning rate (‘n’) = 0.2


        Wi   =   wi + n(t-o) * xi



“The difference between the approach that we've used before we now recalculate every output value for
the instance that will be calculated. We take the newest/updated weights into account after every
calculation. In the previous example we updated the weight after the entire iteration.”

Instance 1


       O1 = w0 + ( X1 * W1 )
       O1 = 0.4 + ( 1 * 0.8 )
       O1 = 1.2

       w0 = Δw        + n   ( t1 – o1 ) * X0
       w0 = 0.4       + 0.2 ( 1 – 1.2 ) * 1
       w0 = 0.36

       w1 = Δw1       + n   ( t1 – o1 ) * X1
       w1 = 0.8       + 0.2 ( 1 – 1.2 ) * -0.2
       w1 = 0.76



Instance 2


       O2 = w0 + ( X1 * W1 )
       O2 = 0.36 + ( 0.5 * 0.76 )
       O2 = 0.74

       w0 = w1   + n    ( t2 – o2 ) * X0
       w0 = 0.36    + 0.2 ( 1 – 0.74 ) * 1
       w0 = 0.412
       w1 = w1   + n   ( t2 – o2 ) * X1
       w1 = 0.76   + 0.2 ( 1 – 0.74 ) * 0.5
       w1 = 0.786


Instance 3


       O3 = w0 + ( X1 * W1 )
       O3 = 0.412 + ( (-0.8)        * 0.786 )
       O3 = -0.217

       w0 = w1   + n  ( t3 – o3 ) * X0
       w0 = 0.412 + 0.2 ( -1 + 0.217) * 1
       w0 = 0.255
       w1 = w1   + n    ( t3 – o3 ) * X1
       w1 = 0.786    + 0.2 ( -1 + 0.217) * -0.8
       w1 = 0.911




7
Assignment	
  5	
  
	
  
Instance 4


       O4 = w0 + ( X1 * W1 )
       O4 = 0.225 + ( (-0.2)   * 0.911 )
       O4 = 0.073

       w0 = w1   + n    ( t4 – o4 ) * X0
       w0 = 0.255    + 0.2 ( -1 – 0.073 ) * 1
       w0 = 0.041
       w1 = w1   + n    ( t4 – o4 ) * X1
       w1 = 0.911    + 0.2 ( -1 – 0.073 ) * -0.2
       w1 = 0.954




8

More Related Content

What's hot (16)

PDF
Maxima & Minima of Functions - Differential Calculus by Arun Umrao
ssuserd6b1fd
 
PPTX
Rules of derivatives 2.2
Lorie Blickhan
 
PDF
Think Like Scilab and Become a Numerical Programming Expert- Notes for Beginn...
ssuserd6b1fd
 
PDF
Decreasing and increasing functions by arun umrao
ssuserd6b1fd
 
PPTX
statistics assignment help
Statistics Homework Helper
 
PDF
What is meaning of epsilon and delta in limits of a function by Arun Umrao
ssuserd6b1fd
 
PPTX
27 power series x
math266
 
PDF
Principle of Definite Integra - Integral Calculus - by Arun Umrao
ssuserd6b1fd
 
PDF
Jacobians new
Cyprian. Konyeha
 
PPT
Algo>Arrays
Ain-ul-Moiz Khawaja
 
PDF
Limit & Continuity of Functions - Differential Calculus by Arun Umrao
ssuserd6b1fd
 
PDF
Lesson 1: Functions and their representations (slides)
Matthew Leingang
 
PPT
Arrays and structures
Mohd Arif
 
PDF
Engr 371 final exam april 1996
amnesiann
 
DOCX
Matlab lab manual
nmahi96
 
PDF
Principle of Function Analysis - by Arun Umrao
ssuserd6b1fd
 
Maxima & Minima of Functions - Differential Calculus by Arun Umrao
ssuserd6b1fd
 
Rules of derivatives 2.2
Lorie Blickhan
 
Think Like Scilab and Become a Numerical Programming Expert- Notes for Beginn...
ssuserd6b1fd
 
Decreasing and increasing functions by arun umrao
ssuserd6b1fd
 
statistics assignment help
Statistics Homework Helper
 
What is meaning of epsilon and delta in limits of a function by Arun Umrao
ssuserd6b1fd
 
27 power series x
math266
 
Principle of Definite Integra - Integral Calculus - by Arun Umrao
ssuserd6b1fd
 
Jacobians new
Cyprian. Konyeha
 
Algo>Arrays
Ain-ul-Moiz Khawaja
 
Limit & Continuity of Functions - Differential Calculus by Arun Umrao
ssuserd6b1fd
 
Lesson 1: Functions and their representations (slides)
Matthew Leingang
 
Arrays and structures
Mohd Arif
 
Engr 371 final exam april 1996
amnesiann
 
Matlab lab manual
nmahi96
 
Principle of Function Analysis - by Arun Umrao
ssuserd6b1fd
 

Viewers also liked (19)

PPTX
Tree pruning
priya_kalia
 
PDF
Data mining assignment 1
BarryK88
 
PPTX
DATA MINING IN RETAIL SECTOR
Renuka Chand
 
PPT
Csc1100 lecture04 ch04
IIUM
 
PPT
05 Conditional statements
maznabili
 
PDF
01 10 speech channel assignment
Ericsson Saudi
 
PPTX
Project_702
Sreelakshmi Dodderi
 
PDF
С++ without new and delete
Platonov Sergey
 
PDF
Data Engineering - Data Mining Assignment
Darran Mottershead
 
DOC
Data mining notes
AVC College of Engineering
 
PDF
Lecture 01 Data Mining
Pier Luca Lanzi
 
PDF
Data mining with weka
Hein Min Htike
 
PPTX
Data mining to predict academic performance.
Ranjith Gowda
 
PPT
4.2 bst
Krish_ver2
 
PPTX
Data Mining – analyse Bank Marketing Data Set
Mateusz Brzoska
 
PDF
DATA MINING on WEKA
satyamkhatri
 
PPTX
Decision trees
Jagjit Wilku
 
PPTX
Naive bayes
Ashraf Uddin
 
Tree pruning
priya_kalia
 
Data mining assignment 1
BarryK88
 
DATA MINING IN RETAIL SECTOR
Renuka Chand
 
Csc1100 lecture04 ch04
IIUM
 
05 Conditional statements
maznabili
 
01 10 speech channel assignment
Ericsson Saudi
 
Project_702
Sreelakshmi Dodderi
 
С++ without new and delete
Platonov Sergey
 
Data Engineering - Data Mining Assignment
Darran Mottershead
 
Data mining notes
AVC College of Engineering
 
Lecture 01 Data Mining
Pier Luca Lanzi
 
Data mining with weka
Hein Min Htike
 
Data mining to predict academic performance.
Ranjith Gowda
 
4.2 bst
Krish_ver2
 
Data Mining – analyse Bank Marketing Data Set
Mateusz Brzoska
 
DATA MINING on WEKA
satyamkhatri
 
Decision trees
Jagjit Wilku
 
Naive bayes
Ashraf Uddin
 
Ad

Similar to Data mining assignment 5 (20)

DOC
BITS C464.doc
butest
 
PDF
The multilayer perceptron
ESCOM
 
PPTX
Deep learning simplified
Lovelyn Rose
 
PDF
Artificial Neural Networks
Stefano Dalla Palma
 
PPTX
Neural Network Back Propagation Algorithm
Martin Opdam
 
PDF
Curve fitting
JULIO GONZALEZ SANZ
 
PDF
AI Lesson 39
Assistant Professor
 
PDF
Lesson 39
Avijit Kumar
 
PPTX
Supervised learning for IOT IN Vellore Institute of Technology
tanishqgupta1102
 
PDF
Midterm
Robert Edwards
 
PDF
Midterm sols
Robert Edwards
 
PDF
Deep learning concepts
Joe li
 
PDF
Introduction to Artificial Neural Network
Qingkai Kong
 
PDF
Errors in the Discretized Solution of a Differential Equation
ijtsrd
 
PDF
Machine Learning
Ashwin P N
 
PPTX
Artificial neural networks - A gentle introduction to ANNS.pptx
AttaNox1
 
PPTX
Python Homework Help
Python Homework Help
 
PDF
Deep learning MindMap
Ashish Patel
 
PDF
Introduction to Machine Learning
Big_Data_Ukraine
 
PDF
CS229 Machine Learning Lecture Notes
Eric Conner
 
BITS C464.doc
butest
 
The multilayer perceptron
ESCOM
 
Deep learning simplified
Lovelyn Rose
 
Artificial Neural Networks
Stefano Dalla Palma
 
Neural Network Back Propagation Algorithm
Martin Opdam
 
Curve fitting
JULIO GONZALEZ SANZ
 
AI Lesson 39
Assistant Professor
 
Lesson 39
Avijit Kumar
 
Supervised learning for IOT IN Vellore Institute of Technology
tanishqgupta1102
 
Midterm sols
Robert Edwards
 
Deep learning concepts
Joe li
 
Introduction to Artificial Neural Network
Qingkai Kong
 
Errors in the Discretized Solution of a Differential Equation
ijtsrd
 
Machine Learning
Ashwin P N
 
Artificial neural networks - A gentle introduction to ANNS.pptx
AttaNox1
 
Python Homework Help
Python Homework Help
 
Deep learning MindMap
Ashish Patel
 
Introduction to Machine Learning
Big_Data_Ukraine
 
CS229 Machine Learning Lecture Notes
Eric Conner
 
Ad

More from BarryK88 (11)

PDF
Data mining test notes (back)
BarryK88
 
PDF
Data mining test notes (front)
BarryK88
 
PDF
Data mining Computerassignment 3
BarryK88
 
PDF
Data mining assignment 2
BarryK88
 
PDF
Data mining assignment 6
BarryK88
 
PDF
Data mining Computerassignment 2
BarryK88
 
PDF
Data mining Computerassignment 1
BarryK88
 
PDF
Semantic web final assignment
BarryK88
 
PDF
Semantic web assignment 3
BarryK88
 
PDF
Semantic web assignment 2
BarryK88
 
PDF
Semantic web assignment1
BarryK88
 
Data mining test notes (back)
BarryK88
 
Data mining test notes (front)
BarryK88
 
Data mining Computerassignment 3
BarryK88
 
Data mining assignment 2
BarryK88
 
Data mining assignment 6
BarryK88
 
Data mining Computerassignment 2
BarryK88
 
Data mining Computerassignment 1
BarryK88
 
Semantic web final assignment
BarryK88
 
Semantic web assignment 3
BarryK88
 
Semantic web assignment 2
BarryK88
 
Semantic web assignment1
BarryK88
 

Recently uploaded (20)

PDF
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
PDF
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
PPTX
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PPTX
BANDHA (BANDAGES) PPT.pptx ayurveda shalya tantra
rakhan78619
 
PPTX
Views on Education of Indian Thinkers J.Krishnamurthy..pptx
ShrutiMahanta1
 
PPTX
How to Set Maximum Difference Odoo 18 POS
Celine George
 
PPTX
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
PPTX
PPT on the Development of Education in the Victorian England
Beena E S
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PDF
People & Earth's Ecosystem -Lesson 2: People & Population
marvinnbustamante1
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PDF
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
PDF
CHILD RIGHTS AND PROTECTION QUESTION BANK
Dr Raja Mohammed T
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
BANDHA (BANDAGES) PPT.pptx ayurveda shalya tantra
rakhan78619
 
Views on Education of Indian Thinkers J.Krishnamurthy..pptx
ShrutiMahanta1
 
How to Set Maximum Difference Odoo 18 POS
Celine George
 
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
PPT on the Development of Education in the Victorian England
Beena E S
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
People & Earth's Ecosystem -Lesson 2: People & Population
marvinnbustamante1
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
CHILD RIGHTS AND PROTECTION QUESTION BANK
Dr Raja Mohammed T
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 

Data mining assignment 5

  • 1. Data mining Assignment week 5 BARRY KOLLEE 10349863
  • 2. Assignment  5     Exercise 1: Perceptrons 1.1 What is the function of the learning rate in the perceptron training rule? Within our perceptrons we take a certain weight into account when calculating the difference between the target and outcome values. This weight it’s purpose is to adjust the actual value which we compare to a certain threshold (i.e. ‘do we play tennis; yes or no?’). The learning rate it’s goal is to define the extend of this weight adjustment. This learning rate can be described as a sensitivity for our calculation of the difference between the target and outcome value. In conclusion we can state that we give a value to this learning rate based on the difference between the target and outcome value. 1.2 What kind of Boolean functions can be modeled with perceptrons and which Boolean functions can not be modeled and why? Within the model of our perceptron we take several Boolean functions into account which we regularly see within the common programming languages. These Boolean conditions are: • AND (‘&&’) • OR (‘||’) • NAND (‘! &&’) • NOR (‘! ||’) The Boolean condition ‘XOR’ can’t be implemented within the perceptron it’s model. When using the XOR Boolean function the output can only be 1 if x1 is not equal to x2 (x1 != x2)1. The XOR Boolean condition can be represented by using combinations of perceptrons (more then 1-level) That’s because we can express the XOR statement using an AND and an OR condition.                                                                                                                 1 Objective C representation of x1 not equal to x2 2
  • 3. Assignment  5     Exercise 2: Weight Updating in Perceptrons Assume the following set of instances with the weights: w0 = 0.4 and w1 = 0.8. The threshold is 0. What are the output values for each instance before the threshold function is applied? What is the accuracy of the model when applying the threshold function? For calculating the output values of the instances we perform the following formula: Instance value = w0 + (x1 * w1) Output value: 1 if((w0 + (x1 * w1) +… +(xn * wn))) > 0 -1 otherwise With these formula’s we can find the output values of every instance within the table. If the result of the instance value is higher then 0 the output value is 1. If this is not the case we set it to -1. Underneath are all formula results and output values. They formula results are given in green and the output values are in red. Instance 1 : Instance 1 = 0.4 + (0.8 * 1.0) Instance 1 = 0.4 + 0.8 Instance 1 = 1.2 Instance 1 > threshold Output value for instance 1 = 1.0 Instance 2 : Instance 2 = 0.4 + (0.8 * 0.5) Instance 2 = 0.4 + 0.4 Instance 2 = 0.8 Instance 2 > threshold Output value for instance 2 = 1.0 Instance 3: Instance 3 = 0.4 + (0.8 * -0.8) Instance 3 = 0.4 - 0.64 Instance 3 = -0.24 Instance 3 < threshold Output value for instance 3 = -1.0 3
  • 4. Assignment  5     Instance 4: Instance 4 = 0.4 + (0.8 * 1.0) + (0.8 * -0.2) Instance 4 = 0.4 - 0.16 Instance 4 = 0.24 Instance 4 > threshold Output value for instance 4 = 1.0 If we compare these output values with the instance it’s Instance Target Output target value. We can state that we have a 75 % accuracy class value th because ¾ of the target classes is equal to it’s respective value output value. 1 1 1 2 1 1 3 -1 -1 4 -1 1 4
  • 5. Assignment  5     Exercise 3: Gradient Descent Consider the data in Exercise 2. Apply the gradient descent algorithm and compute the weight updates for one iteration. You can assume the same initial weights, and threshold as in Exercise 2. Assume that the learning rate = 0.2. To compute the weight update for one iteration we perform the following formula where: • ‘n’ represents the learning rate • ‘o’ represents the output value (from previous exercise) < 1.2 , 0.8, -0.24, 0.24 > • ‘xi’ represents the input value We calculate for every instance: for each wi (instance) { Δwi = n (t – 0) * xi Δwi = wi + Δwi } Instance 1 (output is 1.2) Δw0 = Δw + n ( t2 – o2 ) * X0 Δw0 = 0 + 0.2 ( 1 – 1.2) * 1.0 Δw0 = -0.04 Δw1 = Δw1 + n ( t2 – o2 ) * X1 Δw1 = 0 + 0.2 (1 – 1.2 ) * 1.0 Δw1 = -0.04 Instance 2 (output is 0.8) Δw0 = Δw + n ( t2 – o2 ) * X0 Δw0 = -0.04 + 0.2 ( 1 - 0.8) * 1 Δw0 = 0 Δw1 = Δw1 + n ( t2 – o2 ) * X1 Δw1 = -0.04 + 0.2 (1 – 0.8 ) * 0.5 Δw1 = -0.02 Instance 3 (output 3 = -0.24) Δw0 = Δw + n ( t2 - o2 ) * X0 Δw0 = 0 + 0.2 ( -1 - (-0.24) ) * 1 Δw0 = 0 + 0.2 ( -1 + 0.24 ) * 1 Δw0 = 0.152 Δw1 = Δw1 + n ( t2 – o2 ) * X1 Δw1 = -0.02 + 0.2 ( -1 – (-0.24) ) * ( -0.8 ) Δw1 = -0.02 + 0.2 ( -1 + 0.24 ) * ( -0.8 ) Δw1 = 0.1016 Instance 4 (output 4 = 0.24) Δw0 = Δw + n ( t2 – o2 ) * X0 Δw0 = 0.152 + 0.2 ( -1 - 0.24 ) * 1 Δw0 = -0.4 Δw1 = Δw1 + n ( t2 – o2 ) * X1 Δw1 = -0.1016 + 0.2 ( -1 - 0.24 ) * -0.2 Δw1 = 0.1016 5
  • 6. Assignment  5     Now we do our weight updating: W0 = W0 + ΔW0 W0 = 0.4 + (-o.4) W0 = 0 W1 = W1 + ΔW1 W1 = 0.8 + 0.1512 W1 = 0.9512 Now we could perform another iteration by starting all over again… 6
  • 7. Assignment  5     Exercise 4: Stochastic Gradient Descent Consider the data in Exercise 2. Apply the stochastic gradient descent algorithm and compute the weight updates for one iteration. You can assume the same initial weights, and threshold as in Exercise 2. Assume that the learning rate = 0.2. For applying a stochastistic gradient descent algorithm we use the following formula where: • Threshold (‘t’) = 0 • Learning rate (‘n’) = 0.2 Wi = wi + n(t-o) * xi “The difference between the approach that we've used before we now recalculate every output value for the instance that will be calculated. We take the newest/updated weights into account after every calculation. In the previous example we updated the weight after the entire iteration.” Instance 1 O1 = w0 + ( X1 * W1 ) O1 = 0.4 + ( 1 * 0.8 ) O1 = 1.2 w0 = Δw + n ( t1 – o1 ) * X0 w0 = 0.4 + 0.2 ( 1 – 1.2 ) * 1 w0 = 0.36 w1 = Δw1 + n ( t1 – o1 ) * X1 w1 = 0.8 + 0.2 ( 1 – 1.2 ) * -0.2 w1 = 0.76 Instance 2 O2 = w0 + ( X1 * W1 ) O2 = 0.36 + ( 0.5 * 0.76 ) O2 = 0.74 w0 = w1 + n ( t2 – o2 ) * X0 w0 = 0.36 + 0.2 ( 1 – 0.74 ) * 1 w0 = 0.412 w1 = w1 + n ( t2 – o2 ) * X1 w1 = 0.76 + 0.2 ( 1 – 0.74 ) * 0.5 w1 = 0.786 Instance 3 O3 = w0 + ( X1 * W1 ) O3 = 0.412 + ( (-0.8) * 0.786 ) O3 = -0.217 w0 = w1 + n ( t3 – o3 ) * X0 w0 = 0.412 + 0.2 ( -1 + 0.217) * 1 w0 = 0.255 w1 = w1 + n ( t3 – o3 ) * X1 w1 = 0.786 + 0.2 ( -1 + 0.217) * -0.8 w1 = 0.911 7
  • 8. Assignment  5     Instance 4 O4 = w0 + ( X1 * W1 ) O4 = 0.225 + ( (-0.2) * 0.911 ) O4 = 0.073 w0 = w1 + n ( t4 – o4 ) * X0 w0 = 0.255 + 0.2 ( -1 – 0.073 ) * 1 w0 = 0.041 w1 = w1 + n ( t4 – o4 ) * X1 w1 = 0.911 + 0.2 ( -1 – 0.073 ) * -0.2 w1 = 0.954 8