Question: PLEASE HELP IN PYTHON I ' m having a problem in my perceptron code to plot the linear decision line boundary. I have my patterns

PLEASE HELP IN PYTHON
I'm having a problem in my perceptron code to plot the linear decision line boundary.
I have my patterns as P = np.array([[1,0,0,1],[1,0,1,0],[1,1,1,1]])
I have my targets as T = np.array([1,0,0,0]).
And I have my weights as W = np.array([0.041,-0.7,0.075]) but it can be any random number for the first two components with third one being the bias.
The red dots on the plot are represented as class 0 but the blue dot are represented as class 1.
plt.plot([0,0,1],[0,1,0],'ro')
plt.plot([1],[1],'bo')
This is how I train the network.
def hardlim(x):
return np.where(x >=0,1,0)
A = hardlim(np.dot(W,P))
E = T-A
rate =0.1
while sum(E)!=0:
W = W + rate * np.dot(E, P.T)
A = hardlim(np.dot(W, P))
E = T-A
How do I plot the linear decision boundary line so the network solves it flawselly. I need it so the blue dot is separated from the red dots with a linear line in the plot.
 PLEASE HELP IN PYTHON I'm having a problem in my perceptron

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!