Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
139 views

PLA Perceptron Learning Algorithm

This document provides an introduction to the perceptron learning algorithm (PLA). It defines key concepts like the perceptron, threshold function, and activation function. It then outlines the steps of the PLA, including initializing weights and biases, calculating outputs, updating weights, and repeating. Finally, it proposes applying the PLA to a sonar dataset to classify objects as mines or rocks, and outlines the implementation steps like preprocessing data, training the model in epochs, and validating accuracy on a test set.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
139 views

PLA Perceptron Learning Algorithm

This document provides an introduction to the perceptron learning algorithm (PLA). It defines key concepts like the perceptron, threshold function, and activation function. It then outlines the steps of the PLA, including initializing weights and biases, calculating outputs, updating weights, and repeating. Finally, it proposes applying the PLA to a sonar dataset to classify objects as mines or rocks, and outlines the implementation steps like preprocessing data, training the model in epochs, and validating accuracy on a test set.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Introduction To AI and ML

PLA : Perceptron Learning Algorithm


Presentation

P.Srijith Reddy,
EE19BTECH11041,
Dept. of Electrical Engg.,
IIT Hyderabad.

February 4, 2020

1 / 14
1 Perceptron

2 Threshold Function

3 Steps of algorithm

4 Activation function

5 Application of PLA

2 / 14
Perceptron

In Machine learning ,the perceptron is an algorithm for supervised learning


of binary classifiers.
Binary classifiers : A binary classifier is a function which can decide
whether or not an input, represented by a vector of numbers, belongs to
some specific class
•It is a type of linear classifier, i.e. a classification algorithm that makes its
predictions based on a linear predictor function combining a set of weights
with the feature vector.

3 / 14
Threshold Function

The perceptron is an algorithm for learning a binary classifier called a


threshold function.(f)

f : Rn → B (3.1)
Where B is a single binary value.
(
1 if w · x + b > 0,
f (x) = (3.2)
0 otherwise
where w is a vector of real-valued weights, w.x= m
P
i=1 wi xi ,
where m is the number of inputs to the perceptron, and b is the bias.

4 / 14
Steps of algorithm
Let’s see an example for the algorithm (single-layer).
some variables :
• r is the learning rate of the perceptron. Learning rate is between 0 and 1.
• In machine learning and statistics, the learning rate is a tuning
parameter in an optimization algorithm that determines the step size at
each iteration
 while moving toward a minimum of a loss function.
• D = (x1 , d1 ), ..., (xs , ds )
is the training set of s samples.
•xj is the n − dimensional input vector .
•dj is the desired output value for that input.
• wi (t) is the weight i at time t.

yj (t) = f [w(t).xj ] (4.1)


wi (t + 1) = wi (t) + r .(dj − yi (t))xj,i (4.2)
Here xj,i is the i th feature of j th training input vector
5 / 14
6 / 14
Activation function

The activation function applies a step rule (convert the numerical output
into +1 or -1) to check if the output of the weighting function is greater
than zero or not.
ex: sigmoid function , hyperbolic functions,softmax function.
Error in perceptron
In the Perceptron Learning Rule, the predicted output is compared with
the known output. If it does not match, the error is propagated backward
to allow weight adjustment to happen.

7 / 14
SONAR Data Classification Using Single Layer Perceptrons
Here we have the data of a SONAR data set which contains the data
about 208 patterns obtained by bouncing sonar signals off a metal cylinder
(naval mine) and a rock at various angles and under various conditions.
• A naval mine is a self-contained explosive device placed in water to
damage or destroy surface ships or submarines.
• we need to build a model that can predict whether the object is a naval
mine or rock based on our data set.

8 / 14
Let’s have a look at the information .

9 / 14
IMPLEMENTATION

1.Read and Pre-process the data set:


• At first we will read the CSV file (input data set) using readcsv()
function.
• Then, we will segregate the feature columns (independent variables) and
the output column (dependent variable) as X and y respectively.
• The output column consists of string categorical values as M and R,
signifying Rock and Mine respectively. So, I will label them them as 0 and
1 w.r.t. M and R.
2.Function for One Hot Encoder:
• One Hot Encoder adds extra columns based on number of labels present
in the column. In this case, I have two labels 0 and 1 (for Rock and Mine).
Therefore, two extra columns will be added corresponding to each
categorical value

10 / 14
IMPLEMENTATION

3.Dividing data set into Training and Test Subset


• While working on any deep learning project, we need to divide your data
set into two parts where one of the parts is used for training your deep
learning model and the other is used for validating the model once it has
been trained.
• Training Subset: It is used for training the model
• Test Subset: It is used for validating our trained model.
4.Define Variables and Placeholders
• Learning Rate: The amount by which the weight will be adjusted.
• Training Epochs: No. of iterations
• Cost History: An array that stores the cost values in successive epochs.
• Weight: Tensor variable for storing weight values
• Bias: Tensor variable for storing bias values

11 / 14
IMPLEMENTATION

5.Calculate the Cost or Error


• we will calculate the cost or error produced by our model. Instead of
Mean Squared Error, we will use cross entropy to calculate the error in this
case.
6.Training the Perceptron Model in Successive Epochs
• Now, we will train my model in successive epochs. In each of the
epochs, the cost is calculated and then, based on this cost the optimizer
modifies the weight and bias variables in order to minimize the error.
7.Validation of the Model based on Test Subset
• The accuracy of a trained model is calculated based on Test Subset.
Therefore, at first, we will feed the test subset to my model and get the
output (labels).
• Then, we will compare the output obtained from the model with that of
the actual or desired output and finally, will calculate the accuracy as
percentage of correct predictions out of total predictions made on test
subset.
12 / 14
Output:

13 / 14
Code for SONAR Data Classification Using Single Layer Perceptron
code

14 / 14

You might also like