Issue Feedback
Part2 Building AI. Exercise 20: Logistic Regression
I believe the correct answer should be c1. Below are my code and output. Please verify and check. Thank you!
import math
import numpy as np
x = np.array([4, 3, 0])
c1 = np.array([-.5, .1, .08])
c2 = np.array([-.2, .2, .31])
c3 = np.array([.5, -.1, 2.53])
def sigmoid(z):
# add your implementation of the sigmoid function here
return 1 / (1 + math.exp(-z))
# calculate the output of the sigmoid for x with all three coefficients
c1_sum = np.sum((x - c1) ** 2)
c1_linear = np.sqrt(c1_sum)
c1_sigmoid = sigmoid(c1_linear)
print(f"c1: {c1_sigmoid}")
c2_sum = np.sum((x - c2) ** 2)
c2_linear = np.sqrt(c2_sum)
c2_sigmoid = sigmoid(c2_linear)
print(f"c2: {c2_sigmoid}")
c3_sum = np.sum((x - c3) ** 2)
c3_linear = np.sqrt(c3_sum)
c3_sigmoid = sigmoid(c3_linear)
print(f"c3: {c3_sigmoid}")