All problems
Passive-Aggressive Update
Problem
Take one passive-aggressive update.
With margin loss = 1 - y * (w dot x), return w unchanged when the loss is non-positive. Otherwise return w + tau * y * x with tau = loss / (||x|| ** 2 + 1 / (2C)).
Hint
The step size tau adapts to the feature norm and the aggressiveness C.
Test cases
case 1
in: [[0,0],[1,1],1,1]
expected: [0.4,0.4]
case 2
in: [[1,1],[1,1],1,0.5]
expected: [1,1]
case 3
in: [[0.2,-0.2],[1,2],-1,2]
expected: [0.047619047619047616,-0.5047619047619047]
Starter codePython
def passive_aggressive_update(w, x, y, C):
# Your code here
pass3 test cases · run your code against them in the editor