FunctionRacerProblemsRace

How Well It Ranks

Mediumscikit-learnPython

A classifier that gives chances can be judged by how well it ranks cases: the area under the ROC curve is the chance that a random positive case gets a higher score than a random negative one. Fit a logistic regression on X and y, score every row of X with its chance of being 1, and return that area.

Example 1

X [[1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12]]
y [0,0,0,0,0,0,1,1,1,1,1,1]
returns 1.0

Every 1 gets a higher chance than every 0: a perfect ranking.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More scikit-learn problems