All problems
Representer Theorem Weight Solve
Problem
Solve the regularized kernel system (K + lam*I) * alpha = y for the 2x2 kernel matrix K.
Return the coefficient vector alpha as floats; these are the weights the representer theorem assigns to the training points.
Hint
The ridge penalty lam keeps the kernel system well-conditioned.
Test cases
case 1
in: [[[1,0],[0,1]],[1,2],0]
expected: [1,2]
case 2
in: [[[1,0.5],[0.5,1]],[1,0],1]
expected: [0.5333333333333333,-0.13333333333333333]
case 3
in: [[[2,0],[0,2]],[2,4],2]
expected: [0.5,1]
case 4
in: [[[1,0],[0,1]],[0,0],1]
expected: [0,0]
Starter codePython
def representer_weights(K, y, lam):
# Your code here
pass4 test cases · run your code against them in the editor