Returns the area under the curve for the given list of (x, y)-points. The area is calculated using the trapezoidal rule. For the area under the ROC-curve, the return value is the probability (0.0-1.0) that a classifier will rank a random positive document (True) hi
(curve=[])
| 198 | return sorted([(0.0, 0.0), (1.0, 1.0)] + [(x(*m), y(*m)) for m in tests]) |
| 199 | |
| 200 | def auc(curve=[]): |
| 201 | """ Returns the area under the curve for the given list of (x, y)-points. |
| 202 | The area is calculated using the trapezoidal rule. |
| 203 | For the area under the ROC-curve, |
| 204 | the return value is the probability (0.0-1.0) that a classifier will rank |
| 205 | a random positive document (True) higher than a random negative one (False). |
| 206 | """ |
| 207 | curve = sorted(curve) |
| 208 | # Trapzoidal rule: area = (a + b) * h / 2, where a=y0, b=y1 and h=x1-x0. |
| 209 | return sum(0.5 * (x1 - x0) * (y1 + y0) for (x0, y0), (x1, y1) in sorted(izip(curve, curve[1:]))) |
| 210 | |
| 211 | #### AGREEMENT ##################################################################################### |
| 212 | # +1.0 = total agreement between voters |