I cannot figure out my problem - C3_W1_Anomaly_Detection

Dear community,

I hope you are doing well, I am contacting you regarding my second exercice in this lab: C3 W1 Lab 2

Can someone tell me the shape of p_val ? I assume it is a one dimensional array with “m” attributes ? just like y_val, but the code keep giving me this error :

I initiated the tp, fp, fn to zero and then i made a loop in range (m) to increment these ( example when p_val[i] < epsilon and y[i] == 1 then tp +=1 )

Please help me why they say it is division by zero here

Most likely it’s because your code is giving (tp +fp) equal to zero.

Perhaps your code for computing the tp and fp values is incorrect.

1 Like

Hello TMosh, Thank you very much for your answer, For these values, I used a loop that increments each one, for example : when p_val[i] < epsilon and y[i] == 1 then tp +=1, I assumed that p_val is already calculated, is it correct ?

I think your method is not giving the correct results.

I recommend you read all of the Hint code, it gives methods for computing predictions and all of the metrics using one-line of code that avoids using loops.

Yes, that is correct.

1 Like