Skip to content
CampusEduX

Problem 4: Evaluate Regularized vs Unregularized Models on Test Data

Easypython
Learn the Concept: Regularization (L1/L2)

Problem Description

Write a Python program that trains both a standard Linear Regression model and a Ridge model on a training set, then compares their test set performance (using MSE) to see if regularization improved generalization.

Input

A dataset split into training and test sets.

Output

Test MSE for both the unregularized and regularized models.

Constraints

  • At least 10 data points.

Example Input

text
(A dataset with some noise, split into train/test)

Example Output

text
Linear Regression Test MSE: 15.2 Ridge Test MSE: 11.8

Concepts Covered

LinearRegression, Ridge, mean_squared_error(), generalization comparison.

Related Problems

  • Problem 1: Compare Linear Regression, Ridge, and Lasso Coefficients
    Easy · python
    Solve Problem
  • Problem 2: Observe Lasso Zeroing Out Coefficients
    Easy · python
    Solve Problem
  • Problem 3: Compare Different Alpha Values
    Easy · python
    Solve Problem

Input (stdin)

Output

Run your code to see output here...