Skip to content
DeepForgeby svx
All problems
MediumML Fundamentalsml-311

Quantile Forest Predict

Problem

Predict a quantile from a quantile regression forest's leaf samples using linear interpolation between order statistics at position q * (n - 1).

Empty input returns 0.0.

Hint

Quantile forests propagate the empirical leaf distribution instead of a mean.

Test cases

case 1
in: [[1,2,3,4],0.5]
expected: 2.5
case 2
in: [[1,2,3,4],0.9]
expected: 3.7
case 3
in: [[1,2,3,4],0]
expected: 1
case 4
in: [[],0.5]
expected: 0
Starter codePython
def quantile_forest_predict(samples, q):
    # Your code here
    pass

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