Challenge - 5 Problems
Elastic Net Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Understanding Elastic Net Regularization
Which statement best describes the Elastic Net regularization technique in machine learning?
Attempts:
2 left
💡 Hint
Think about how Elastic Net mixes two types of penalties.
✗ Incorrect
Elastic Net regularization adds both L1 (lasso) and L2 (ridge) penalties to the loss function. This helps select important features (like L1) and also keeps correlated features grouped (like L2).
❓ Predict Output
intermediate2:00remaining
Output of Elastic Net Regression Coefficients
What will be the output coefficients after fitting Elastic Net regression with alpha=1.0 and l1_ratio=0.5 on the given data?
ML Python
from sklearn.linear_model import ElasticNet import numpy as np X = np.array([[1, 2], [2, 3], [3, 4], [4, 5]]) y = np.array([3, 5, 7, 9]) model = ElasticNet(alpha=1.0, l1_ratio=0.5, random_state=0) model.fit(X, y) coefficients = model.coef_ print(coefficients)
Attempts:
2 left
💡 Hint
Check how Elastic Net balances L1 and L2 penalties with given parameters.
✗ Incorrect
With alpha=1.0 and l1_ratio=0.5, Elastic Net shrinks coefficients moderately. The output coefficients are approximately [0.5, 1.0].
❓ Hyperparameter
advanced2:00remaining
Effect of l1_ratio in Elastic Net
What happens to the Elastic Net model when the l1_ratio parameter is set to 1.0?
Attempts:
2 left
💡 Hint
l1_ratio controls the mix between L1 and L2 penalties.
✗ Incorrect
When l1_ratio=1.0, Elastic Net applies only the L1 penalty, making it equivalent to Lasso regression.
❓ Metrics
advanced2:00remaining
Choosing Regularization Strength Alpha
Which method is best to select the optimal alpha parameter for Elastic Net to balance bias and variance?
Attempts:
2 left
💡 Hint
Think about how to avoid overfitting and underfitting.
✗ Incorrect
Cross-validation tests different alpha values and selects the one that gives the best performance on unseen data, balancing bias and variance.
🔧 Debug
expert2:00remaining
Debugging Elastic Net Model Training Error
You run this code but get a ValueError: 'alpha must be positive'. Which option fixes the error?
ML Python
from sklearn.linear_model import ElasticNet model = ElasticNet(alpha=0, l1_ratio=0.5) model.fit([[1, 2], [3, 4]], [5, 6])
Attempts:
2 left
💡 Hint
Check the error message about alpha value.
✗ Incorrect
ElasticNet requires alpha to be positive. Setting alpha=0 causes the error. Changing alpha to a positive number fixes it.