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.
Lösung
Danke für Ihr Feedback!
single
Fragen Sie AI
Fragen Sie AI
Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen
Awesome!
Completion rate improved to 8.33
Challenge: Compare Ridge and Lasso on Real Data
Swipe um das Menü anzuzeigen
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.
Lösung
Danke für Ihr Feedback!
single