Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Challenge: Compare Ridge and Lasso on Real Data | Regularization Fundamentals
Feature Selection and Regularization Techniques

bookChallenge: 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:

  1. Load the dataset and split it into training and testing sets (70% / 30%).
  2. Fit two models:
    • A Ridge regression model with alpha=1.0
    • A Lasso regression model with alpha=0.1
  3. Evaluate both models using R² score and Mean Squared Error (MSE) on the test set.
  4. Compare their coefficients to observe how Lasso drives some coefficients toward zero (feature selection effect).
  5. Print the metrics and model coefficients for each model.

Рішення

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 4
single

single

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

close

Awesome!

Completion rate improved to 8.33

bookChallenge: 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:

  1. Load the dataset and split it into training and testing sets (70% / 30%).
  2. Fit two models:
    • A Ridge regression model with alpha=1.0
    • A Lasso regression model with alpha=0.1
  3. Evaluate both models using R² score and Mean Squared Error (MSE) on the test set.
  4. Compare their coefficients to observe how Lasso drives some coefficients toward zero (feature selection effect).
  5. Print the metrics and model coefficients for each model.

Рішення

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 4
single

single

some-alt