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
What does the second column do as alpha grows, and what does the third column print?
Sign in to answer questions and track your progress
Sign In