How Well It Ranks
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
12 <= len(X) <= 60, both labels present- 1 to 3 columns
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More scikit-learn problems
- No PeekingMedium
- Scale Then VoteMedium
- Shrunken SlopesMedium
- Two Main DirectionsMedium
- Words to CountsMedium
- How Many GroupsHard
- Keep the Useful ColumnsHard
- Leak-Free ScoreHard