In the final lab of Week 3 for the Supervised ML course, Exercise 4 - I have been over all my notes and the practice labs, and I really can not see were we the “predict function” was discussed.
While the “hints” are ok- they do fully explain how this function is implemented—
Thus with much trial and error- and RESEARCH- I have come as far as the following :
Test your predict code
np.random.seed(1)
tmp_w = np.random.randn(2)
tmp_b = 0.3
tmp_X = np.random.randn(4, 2) - 0.5
tmp_p = predict(tmp_X, tmp_w, tmp_b)
print(f’Output of predict: shape {tmp_p.shape}, value {tmp_p}')
UNIT TESTS
predict_test(predict)
Output of predict: shape (4,), value [0 1 1 1]
*This matches the expected output- BUT with Errors that I do not have any idea how to fix.
ValueError Traceback (most recent call last)
in
9
10 # UNIT TESTS
—> 11 predict_test(predict)
~/work/public_tests.py in predict_test(target)
67 expected_1 = [1., 1., 1., 0., 1., 0., 0., 1.]
68 if np.allclose(result, wrong_1):
—> 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}"
ValueError: Did you apply the sigmoid before applying the threshold?
***Train Accuracy: 60.000000
I would really value some personal assistance- vs. generalized Tech speak.
Thanks in advance
