Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Regularized Regression Workflow | Advanced Regularization and Model Interpretation
Feature Selection and Regularization Techniques

bookChallenge: Regularized Regression Workflow

Opgave

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.

Løsning

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 3. Kapitel 4
single

single

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

Suggested prompts:

Can you explain that in more detail?

What are the main benefits or drawbacks?

Can you give me an example?

close

Awesome!

Completion rate improved to 8.33

bookChallenge: Regularized Regression Workflow

Stryg for at vise menuen

Opgave

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.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 3. Kapitel 4
single

single

some-alt