For logistic regression, do we need to adapt this function so that we apply the sigmoid function to the np.dot(data, weights)?
Code
def predict_labels(weights, data, logistic):
"""Generates class predictions given weights, and a test data matrix"""
if logistic:
threshold = 0.5
else:
threshold = 0
np.dot(data, weights) > 0 if and only if sigmoid(np.dot(data, weights)) > 0.5
So if I understand your question correctly, you should just make sure that threshold=0 in your code (i.e. logistic=False in your code which is probably a bit misleading as it should be vice versa).
Predictions in logistic regression
For logistic regression, do we need to adapt this function so that we apply the sigmoid function to the np.dot(data, weights)?
Code
def predict_labels(weights, data, logistic):
"""Generates class predictions given weights, and a test data matrix"""
if logistic:
threshold = 0.5
else:
threshold = 0
Code
Hi,
np.dot(data, weights) > 0 if and only if sigmoid(np.dot(data, weights)) > 0.5
So if I understand your question correctly, you should just make sure that
threshold=0
in your code (i.e.logistic=False
in your code which is probably a bit misleading as it should be vice versa).Add comment