Challenge: Compare Ridge and Lasso on Real Data
Swipe to start coding
In this challenge, you will compare Ridge and Lasso regression on a real dataset to see how regularization strength affects model performance and coefficient magnitudes.
You will use the Diabetes dataset from scikit-learn, which is a standard regression dataset with 10 input features and a continuous target variable.
Your goals are:
- Load the dataset and split it into training and testing sets (70% / 30%).
- Fit two models:
- A Ridge regression model with
alpha=1.0 - A Lasso regression model with
alpha=0.1
- A Ridge regression model with
- Evaluate both models using R² score and Mean Squared Error (MSE) on the test set.
- Compare their coefficients to observe how Lasso drives some coefficients toward zero (feature selection effect).
- Print the metrics and model coefficients for each model.
Solução
Obrigado pelo seu feedback!
single
Pergunte à IA
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo
Awesome!
Completion rate improved to 8.33
Challenge: Compare Ridge and Lasso on Real Data
Deslize para mostrar o menu
Swipe to start coding
In this challenge, you will compare Ridge and Lasso regression on a real dataset to see how regularization strength affects model performance and coefficient magnitudes.
You will use the Diabetes dataset from scikit-learn, which is a standard regression dataset with 10 input features and a continuous target variable.
Your goals are:
- Load the dataset and split it into training and testing sets (70% / 30%).
- Fit two models:
- A Ridge regression model with
alpha=1.0 - A Lasso regression model with
alpha=0.1
- A Ridge regression model with
- Evaluate both models using R² score and Mean Squared Error (MSE) on the test set.
- Compare their coefficients to observe how Lasso drives some coefficients toward zero (feature selection effect).
- Print the metrics and model coefficients for each model.
Solução
Obrigado pelo seu feedback!
single