Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.
image text in transcribed

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

Students also viewed these Databases questions

Question

Use a three-step process to develop effective business messages.

Answered: 1 week ago