All problems
LIME Kernel Weight
Problem
Compute the LIME locality kernel weight: exp(-distance^2 / width^2).
Return 0.0 when width <= 0.
Hint
The kernel decays with distance so nearby perturbations dominate the surrogate fit.
Test cases
case 1
in: [2,2]
expected: 0.36787944117144233
case 2
in: [0,2]
expected: 1
case 3
in: [1,0]
expected: 0
case 4
in: [3,1]
expected: 0.00012340980408667956
Starter codePython
import math
def lime_kernel_weight(distance, width):
# Your code here
pass4 test cases · run your code against them in the editor