Skip to content
C

Problem 4: Calculate R² for a Trained Regression Model

Easypython

Problem Description

Write a Python program that trains a Linear Regression model, generates predictions on a test set, and calculates the R² score to evaluate model fit.

Input

Training data and a separate test set.

Output

The R² score on the test set.

Constraints

  • At least 5 data points in each set.

Example Input

text
(A Linear Regression model trained on 5 points, tested on 3 new points)

Example Output

text
R² Score: 0.91

Concepts Covered

LinearRegression, r2_score(), train-test evaluation.

Input (stdin)

Output

Run your code to see output here...