Implement the perceptron learning algorithm (PLA) and linear regression (pseudoinverse) discussed in class. Please separate the problem in 3 main steps, for each step indicate the command and describe...

1 answer below »

Implement the perceptron learning algorithm (PLA) and linear regression (pseudoinverse) discussed in class. Please separate the problem in 3 main steps, for each step indicate the command and describe what it executes.
1) Generation of the data and labeling.


2) Apply and describe PLA.
3) Apply and describe Linear regression by computing the pseudo inverse.


Requirement:




  1. You are required not to use the existing classifier and regression function in library.




  2. Please submit your code in python



Answered 1 days AfterOct 17, 2021

Answer To: Implement the perceptron learning algorithm (PLA) and linear regression (pseudoinverse) discussed in...

Darshan answered on Oct 19 2021
140 Votes
#import numpy for numeric array
import numpy as npa
#import matplotlib for plot
import matplotli
b.pyplot as plot
#Generation of the data and labeling.
m = 250
x1 = 8*npa.random.rand(m, 1)
x2 = 7*npa.random.rand(m, 1) - 3
g = 0.8*x1 + x2 - 3
C1 = npa.where(g >= 1)
C0 = npa.where(g < -1)
#Apply and describe Linear regression
C1 = npa.where(g >= 1)[0]
C0 = npa.where(g < -1)[0]
plot.figure(figsize=(10, 8))
plot.plot(x1[C1], x2[C1], 'ro', alpha = 0.4, label = 'C1')            
plot.plot(x1[C0], x2[C0], 'bo',...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here