All problems
SMO Pair Update Lite
Problem
Perform the SMO update of a pair of SVM dual variables.
For y_i != y_j, L = max(0, a_j - a_i) and H = min(C, C + a_j - a_i); otherwise L = max(0, a_i + a_j - C) and H = min(C, a_i + a_j). Set a_j_new = clip(a_j + y_j * (E_i - E_j) / eta, L, H) and a_i_new = a_i + y_i * y_j * (a_j - a_j_new). Return [a_i_new, a_j_new].
Hint
The box constraints keep the updated multipliers feasible for the equality constraint.
Test cases
case 1
in: [0.2,0.3,1,-1,0.5,-0.2,2,1]
expected: [0,0.09999999999999998]
case 2
in: [0.5,0.5,1,1,0.4,0.1,1,1]
expected: [0.19999999999999996,0.8]
case 3
in: [0.9,0.9,1,1,1,0,0.5,1]
expected: [0.8,1]
case 4
in: [0.2,0.6,1,-1,0.1,0.05,2,1]
expected: [0.175,0.575]
Starter codePython
def smo_pair_update(a_i, a_j, y_i, y_j, E_i, E_j, eta, C):
# Returns [a_i_new, a_j_new]
# Your code here
pass4 test cases · run your code against them in the editor