In the final lab of Week 3 for the Supervised ML course, under section 2.8 Evaluating logistic regression, Exercise 4, I’m asked to complete a predict function. I cannot find any situation in the previous labs where we were introduced to this predict function, and therefore do not know how to structure it, as I have no examples to go from.
I have followed the hint instructions which start out with “# Calculate f_wb (exactly how you did it in the compute_cost function above)”, so I copied and pasted my compute_cost function exactly as I had it above, which causes a lot of errors:
AssertionError Traceback (most recent call last)
<ipython-input-71-568191cf1844> in <module>
9
10 # UNIT TESTS
---> 11 predict_test(predict)
~/work/public_tests.py in predict_test(target)
69 raise ValueError("Did you apply the sigmoid before applying the threshold?")
70 assert result.shape == (len(X),), f"Wrong length. Expected : {(len(X),)} got: {result.shape}"
---> 71 assert np.allclose(result, expected_1), f"Wrong output: Expected : {expected_1} got: {result}"
72
73 b = -1.7
AssertionError: Wrong output: Expected : [1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0] got: [0. 0. 0. 0. 0. 0. 0. 1.]
Update: After trying a few different things, I now have a smaller error that is
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-126-568191cf1844> in <module>
5 tmp_X = np.random.randn(4, 2) - 0.5
6
----> 7 tmp_p = predict(tmp_X, tmp_w, tmp_b)
8 print(f'Output of predict: shape {tmp_p.shape}, value {tmp_p}')
9
TypeError: predict() missing 1 required positional argument: 'b'
Please advise.
Thank you.