All problems
Conformal Prediction Interval Lite
Problem
Build a conformal prediction interval around a point prediction. Take the alpha-quantile of absolute calibration scores (sorted index ceil((1 - alpha) * n) - 1, clamped to [0, n-1]) and return [prediction - q, prediction + q].
Return [prediction, prediction] when scores is empty.
Hint
Conformal intervals are symmetric here because absolute scores are used.
Test cases
case 1
in: [5,[1,-2,3],0.5]
expected: [3,7]
case 2
in: [0,[0.1,0.2,0.3,0.4],0.75]
expected: [-0.1,0.1]
case 3
in: [10,[],0.5]
expected: [10,10]
case 4
in: [2,[1,1],1]
expected: [1,3]
Starter codePython
import math
def conformal_interval_lite(prediction, scores, alpha):
# Your code here
pass4 test cases · run your code against them in the editor