Challenge: Regularized Regression Workflow
Tarefa
Swipe to start coding
In this challenge, you’ll build and compare Ridge and Lasso regression models using a clean machine learning workflow.
Your goal is to:
- Load the Diabetes dataset from scikit-learn.
- Split it into training and test sets (
test_size=0.3,random_state=42). - Build two separate pipelines, each with:
StandardScaler()for feature scaling.- Either
Ridge(alpha=1.0)orLasso(alpha=0.01, random_state=42)for regression.
- Fit both models, evaluate their R² scores on the test set, and print them.
- Print the L2 (Ridge) and L1 (Lasso) coefficient norms to compare regularization effects.
Solução
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 3. Capítulo 4
single
Pergunte à IA
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo
Suggested prompts:
Can you explain that in more detail?
What are the main benefits or drawbacks?
Can you give me an example?
Awesome!
Completion rate improved to 8.33
Challenge: Regularized Regression Workflow
Deslize para mostrar o menu
Tarefa
Swipe to start coding
In this challenge, you’ll build and compare Ridge and Lasso regression models using a clean machine learning workflow.
Your goal is to:
- Load the Diabetes dataset from scikit-learn.
- Split it into training and test sets (
test_size=0.3,random_state=42). - Build two separate pipelines, each with:
StandardScaler()for feature scaling.- Either
Ridge(alpha=1.0)orLasso(alpha=0.01, random_state=42)for regression.
- Fit both models, evaluate their R² scores on the test set, and print them.
- Print the L2 (Ridge) and L1 (Lasso) coefficient norms to compare regularization effects.
Solução
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 3. Capítulo 4
single