0
0
ML Pythonprogramming~20 mins

Regularization (Ridge, Lasso) in ML Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Regularization Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Ridge vs Lasso Regularization

Which statement correctly describes the main difference between Ridge and Lasso regularization?

ALasso regularization always performs better than Ridge because it uses both L1 and L2 penalties.
BRidge adds an L1 penalty that sets coefficients to zero, while Lasso adds an L2 penalty that only shrinks coefficients.
CBoth Ridge and Lasso add L2 penalties but differ in how they scale the penalty term.
DRidge adds an L2 penalty which shrinks coefficients but does not set any to zero, while Lasso adds an L1 penalty that can set some coefficients exactly to zero.
Attempts:
2 left
Predict Output
intermediate
2:00remaining
Output of Lasso Regression Coefficients

What will be the output coefficients after fitting Lasso regression on the given data?

ML Python
from sklearn.linear_model import Lasso
import numpy as np

X = np.array([[1, 2], [2, 3], [3, 4], [4, 5]])
y = np.array([3, 5, 7, 9])

model = Lasso(alpha=1.0)
model.fit(X, y)
coefficients = model.coef_
print(coefficients)
A[0. 0.]
B[1. 1.]
C[0. 2.]
D[0.5 1.5]
Attempts:
2 left
Hyperparameter
advanced
2:00remaining
Effect of Increasing Alpha in Ridge Regression

What happens to the coefficients of a Ridge regression model as the regularization parameter alpha increases?

ACoefficients remain unchanged regardless of alpha value.
BCoefficients shrink towards zero, reducing model complexity and overfitting.
CCoefficients become larger in magnitude to fit the training data better.
DCoefficients become exactly zero, performing feature selection.
Attempts:
2 left
Metrics
advanced
2:00remaining
Choosing Between Ridge and Lasso Using Cross-Validation

You have trained both Ridge and Lasso regression models on the same dataset using cross-validation. The Ridge model has a mean squared error (MSE) of 4.5, and the Lasso model has an MSE of 4.7. Which model should you choose and why?

AChoose Ridge because it has a lower MSE, indicating better predictive performance.
BChoose Lasso because it performs feature selection even if MSE is higher.
CChoose Lasso because it always generalizes better than Ridge.
DChoose Ridge only if the number of features is greater than the number of samples.
Attempts:
2 left
🔧 Debug
expert
2:00remaining
Debugging Lasso Regression with Unexpected Zero Coefficients

You trained a Lasso regression model on your dataset, but all coefficients are zero. What is the most likely cause?

AThe alpha parameter is set too high, causing all coefficients to shrink to zero.
BThe dataset has too many features, causing Lasso to fail.
CThe model was trained without fitting the data.
DThe target variable is constant, so coefficients are zero.
Attempts:
2 left