This cumulative count depends on previous calculation and the set ordered by score. 
For the same score value (that is the threshold that later define each point of the curve) could be 2 cases on the "IF(r.c_actual=r.c_modeled" operation but depending on the counter also the outputs are different. Finally, only one value is needed from each "score" set of values, that is why DEDUP is used later.
I did it this way because it simplifies the caculations in one line, I will give a shot to GROUP by (classifier, score and r.c_actual=r.c_modeled) and find out if I can get the same results.