The value of a weight vector is given as (w1=3, w2=-2, w0=1) for a linear model with soft threshold (sigmoid) function f(x). Define a decision boundary, where the values of the feature vector x result in f(x)=0.5. Plot the decision boundary in two dimensions.
SOLUTION:
1.
We consider a linear sample between -5 to 5 consisting of 100 hunderd sample sample to plot the sigmoid function and its decision boundary.
In python, a sigmoid function can be written as
def sigmoid(z):return 1/(1 + np.exp(-z))
we plot the sigmoid function and decision boundary with the following code:
import matplotlib.pyplot as plt
import numpy as np
x_sample = np.linspace(-5,5,100)
plt.plot(x_sample, sigmoid(x_sample))
plt.plot([-5,5],[.5,.5])
plt.xlabel("z")
plt.ylabel("sigmoid(z)")
plt.show()
The 2D graph of sigmoid function and decision boundary look like:
please give me thumb up
Get Answers For Free
Most questions answered within 1 hours.