Code Anomaly detection

Hi mentors

I need help to build further understanding here

def select_threshold(y_val, p_val): 
# mentor edit: code removed

Q1 step_size why do we have this function, why divided by 1000.
Q2 Meaning F1 > best_F1

Hi @Jasmine7

Q1 → The step size is used to find the increments to evaluate potential epsilon when searching for the best threshold (for maximizing the F1 score). By dividing by 1000, you are making sure that the epsilon values are sampled at fine step sizes.

Example : If p_val ranges from 0.01 to 0.99, the range is 0.99 - 0.01 = 0.98 . Dividing by 1000 gives a step size of 0.00098 , which means you’ll evaluate epsilon at 0.01, 0.01098, 0.01196, ..., 0.98902, 0.99 .

Q2 → It is comparing the current F1 score (calculated for the current threshold epsilon) to the best F1 score found so far.

1 Like

Please do not post your code on the forum. That’s not allowed by the Code of Conduct.

If a mentor needs to see your code, we’ll contact you with instructions.

Thanks so much @alireza

1 Like

You can share any error or assert messages.

The Code of Conduct can be found here. It’s in the “Code of Conduct Category” thread.