C3_W1_Anomaly_Detection errors

Hello, here is my code:

    for epsilon in np.arange(min(p_val), max(p_val), step_size):
      ### START CODE HERE ### 
      # moderator edit: code removed
      ### END CODE HERE ###

After run the test code, I got the error as following:
Best epsilon found using cross-validation: 8.990853e-05
Best F1 on Cross Validation Set: 0.056962

AssertionError Traceback (most recent call last)
in
6
7 # UNIT TEST
----> 8 select_threshold_test(select_threshold)

~/work/public_tests.py in select_threshold_test(target)
7
8 best_epsilon, best_F1 = target(y_val, p_val)
----> 9 assert np.isclose(best_epsilon, 0.04, atol=0.3 / 1000), f"Wrong best_epsilon. Expected: {0.04} got: {best_epsilon}"
10 assert best_F1 == 1, f"Wrong best_F1. Expected: 1 got: {best_F1}"
11

AssertionError: Wrong best_epsilon. Expected: 0.04 got: 0.00029

What is the problem? Thanks!

First, please don’t post your code on the forum. That’s not allowed by the Code of Conduct.

Second, your code is modifying the p_val variable. That’s a bad idea, since you need the original p_val data for every iteration of different epsilon values.

So use a different variable to save your predictions.

Hi,
So sorry about posting code here, won’t do again.

And thanks, the error gone when using a new variable to save predictions for every epsilon iteration. It’s a stupid mistake seems I ran out of my energy last night:)