Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Regularized Regression Workflow | Advanced Regularization and Model Interpretation
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Feature Selection and Regularization Techniques in Python
close
SectionΒ 3. ChapterΒ 4
single

single

bookChallenge: Regularized Regression Workflow

Swipe to show menu

Task

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:

  1. Load the Diabetes dataset from scikit-learn.
  2. Split it into training and test sets (test_size=0.3, random_state=42).
  3. Build two separate pipelines, each with:
    • StandardScaler() for feature scaling.
    • Either Ridge(alpha=1.0) or Lasso(alpha=0.01, random_state=42) for regression.
  4. Fit both models, evaluate their RΒ² scores on the test set, and print them.
  5. Print the L2 (Ridge) and L1 (Lasso) coefficient norms to compare regularization effects.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 3. ChapterΒ 4
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

some-alt