Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4 . Programming a perceptron: Consider a classification problem of two continuous input variables and a binary class variable. Apply perceptron weight training algorithm to

4. Programming a perceptron: Consider a classification problem of two continuous input variables and a binary class variable. Apply perceptron weight training algorithm to find a line that seperates the two classes.
Choose a learning rate
Stat with initial weights for each variable and a bias term which are small numbers: uniformly distributed between -0.1 and +0.1
Iterate until accuracy is 100% for P1 or accuracy reachs a reasonable value for P2
At each step
Update weights and bias
Monitor accuracy and the weights and bias
When stopped: monitor the final weights and accuracy
Solve the problem for the two datasets P1 and P2. P1 isa linearly seperable data whereas P2 cannot be perectly separated by a single perceptron.
Each problem is solved by a different program in Python
Input Generation
Generate 100 data points of two continuous inputs uniformly distributed between 0 and 10
Make s scatter plot of your data
These are the input features of two continuous variable used in both P1 and P2
P1: A Linearly Seperable Dataset
Labesl the data with two lnearly seperable classes
Choose a line in 2-dimensional input space specified by w0,w1 and w3 the three we4igths of the perceptron
Such as L: w1*x1+ w2*x2+ w0=0
Such as L: 1*x1+1*x210=0
Where x1 and x2 are input features and w0,w1 and w2 are weigths to be learned by the perceptron
Here as you set the line such that
Above lhis line if L >=0 the output class is yes or 1
f L <0 the class is not buy or 0
For all 100 input of two features between 0 and 10
Apply the above formula to generate a label
So at the end of labeling approximately 50% of your date is labeled as class 1 and the other 50% is of class 2
Then implement a percvepron training alorithm in Python
Start with initial weights
Choose a learning rate
In each eopch
Pass over all data point
and make a littel update of the weights
Aster several epochs
plot the labeled daa together with the learned line
Monitor the accuracy rate as well
Note Since the problem is linearly seperable by the line whose equation you know
The final accuracy shoud be 100%
You know the line as the generator of he datga.
Let the perceptrn learn it: learn the weigths w0,w1 and w2
P2 A dataset that is not linearly seperable
In P1 ht eline you set say x1 x210=10 perfectlyseperates the two classes
Say above it is class 1 and below it as class 0
Now lst us generatre classes assign labels to the say 100 inputs so as to generate a data set that is not linearly seperable.
Think of two additional lines just 2 units above and below the seperating line.
Say LU: x1+ x2-12=0 and
LL: x1+ x28=0
How to label an non-seperable class
Pass over all 100 data
If LU is satisfied x1+ x2-12>=0 Label as class 1
els if LL is satisfied x1+ x2-8<=0 Label as class 0
else // data is in beween LU and LU
generate a ranom number between 0 and 1 say r
if r <0.5 label as class1 otherwise label as class 0
This is how the inputs are labeled as a not linearly seperable data
Tht is a line a single perceptron cannot seperarte with 100% accuracy
Make a sctter plot of the data includeing the labeled classes
Appy the perceptron algorithm you depelop to this data
After several 10s or 100s of eqochs
Monitor the accuracy rate or the error rate
Make scatter plot of the data as well as the lerend line
Make a comperison with P1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions