# Loop over each example
for i in range(m):
# Calculate f_wb (exactly how you did it in the compute_cost function above)
z_wb = 0
# Loop over each feature
for j in range(n):
# Add the corresponding term to z_wb
z_wb_ij = X[i, j] * w[j]
z_wb += z_wb_ij
# Add bias term
z_wb += b
# Calculate the prediction from the model
f_wb = sigmoid(z_wb)
# Calculate the prediction for that training example
p[i] = p[i] = f_wb >= 0.5 # Your code here to calculate the prediction based on f_wb
I get this indent error:
File “”, line 24
for i in range(m):
^
IndentationError: unexpected indent
I’ve tried a number of things to correct it, but no progress.
It depends on the editor. I’m going by memory here, I think this works with the Coursera Labs.
Delete all of the indentation, so every line of code starts in column 1.
I think a shortcut for this is to click-and-drag all of the text, then press shift-tab a couple of times. That will remove indentation.
Then re-insert the indentation.
You can select blocks of text and indent the whole block with the tab key.
Avoid mixing spaces and tabs.
Most python editors automatically change tabs into a configurable number of spaces. Four is typical.