Optimization AlgorithmsMedium
One SGD Step for Matrix Factorization
~15 mincode completion
Implement mf_sgd_step(rating, mu, b_u, b_i, p_u, q_i, lr, reg) returning the updated parameters as one array: [b_u, b_i, *p_u, *q_i].
Where this shows up
~15 min
••••••••••••••••
8 employers weight this skill
4 big tech firms, 2 quant funds, 1 frontier lab, 1 autonomy company. Top match scores 92.
Python
import numpy as np
def mf_sgd_step(rating, mu, b_u, b_i, p_u, q_i, lr, reg):
"""
One SGD step of regularized biased matrix factorization.
Args:
rating: observed rating r_ui
mu: global mean (not updated)
b_u: user bias
b_i: item bias
p_u: (k,) user embedding
q_i: (k,) item embedding
lr: learning rate eta
reg: regularization strength lambda
Returns:
(2 + 2k,) array [b_u, b_i, p_u..., q_i...] after the step
"""
# YOUR CODE HERE
pass