Loading...
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
Control overfitting by penalizing large weights. Compare L1 and L2 intuitively.
L1 encourages sparsity (some weights exactly zero). L2 shrinks all weights smoothly.
# L2 ridge objective
loss = mse(y_true, y_pred) + lam * (w**2).sum()
# L1 lasso objective
loss = mse(y_true, y_pred) + lam * abs(w).sum()