Error in anomly detection in LDR circuit

Can someone help??
1

2

3

Where did you define your API key, Device ID , frame size, MUL factor?

I defined it in top of the program but excluded it in the screenshot as it was unnecessary

Correction in comp function - Var+= math.pow((data1-Mn),2)

actually, in the function comp i have named the parameter data so it won’t affect as the variable data will have the same values as data1,but still I’ll try it once

You have mixed up history data and computed data. Do the correction first.