Skip to content
DeepForgeby svx
All problems
HardML Fundamentalsml-324

Bootstrap AUC Confidence Interval

Problem

Bootstrap a confidence interval for the ROC AUC. Seed random, draw n_boot resamples that keep the positive and negative score lists separate, and compute a tie-aware AUC where ties count one half. Sort the replicates and return [lower, upper] at indices int(0.025 * n_boot) and int(0.975 * n_boot), clamped to the last index. Return [0.0, 0.0] when a class is missing.

Hint

Resample positives and negatives separately so every replicate keeps the original class balance.

Test cases

case 1
in: [[0,0,1,1],[0.1,0.4,0.35,0.8],200,42]
expected: [0,1]
case 2
in: [[1,0,1,0],[0.9,0.8,0.7,0.6],100,7]
expected: [0,1]
case 3
in: [[1,1,1],[0.1,0.5,0.9],50,1]
expected: [0,0]
case 4
in: [[],[],50,1]
expected: [0,0]
case 5
in: [[1,0],[0.5,0.5],100,3]
expected: [0.5,0.5]
Starter codePython
import random

def bootstrap_auc_ci(y_true, scores, n_boot, seed):
    # Returns [lower, upper]
    # Your code here
    pass

5 test cases · run your code against them in the editor