I'm new to Torch, and I am working on a problem where I have to depict the Receiver Operating Characteristic (ROC) curves and their Areas Under the Curve (AUC).
I have to arrays: TPrate
on the y axis and FPrate
on the x axis, having both size n
How could I compute the Area Under the Curve of this function in Torch7 or Lua?
I also found this code from JayClascoe.com but I don't know how to use its functions.
You won't be able to use the code from JayClascoe as it works with functions and yours is a set of points. Assuming FPrate
has x values for x coordinate sorted and TPrate
has corresponding values, you can use Trapezoidal rule. Something like this may work:
local area = 0
for i = 2, n do
area = area + (FPrate[i] - FPrate[i-1]) * (TPrate[i-1] + TPrate[i])/2
end