Counting The Zeros

X has 50 features and 500 rows, all standardized.

from sklearn.linear_model import Lasso, Ridge

for a in [0.01, 0.1, 1.0]:
    l = Lasso(alpha=a).fit(X, y)
    r = Ridge(alpha=a).fit(X, y)
    print(a, (l.coef_ == 0).sum(), (r.coef_ == 0).sum())

The two objectives are

12n∥Xw−y∥22+α∥w∥1and∥Xw−y∥22+α∥w∥22\frac{1}{2n}\lVert Xw - y \rVert_2^2 + \alpha \lVert w \rVert_1 \qquad\text{and}\qquad \lVert Xw - y \rVert_2^2 + \alpha \lVert w \rVert_2^2

What does the second column do as alpha grows, and what does the third column print?

A

Both columns print 0 at every alpha: the exact equality test fails on floating point even for coefficients the penalty drove to zero.

B

The second column climbs toward 50; the third prints 0 at every alpha.

C

Both columns climb toward 50, the second just reaching it at a smaller alpha than the third.

D

The second column prints 0 at every alpha and the third climbs toward 50.