Problem 4: Calculate R² for a Trained Regression Model
Easypython
Learn the Concept: Regression Metrics (MAE, MSE, RMSE, R²)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
textR² Score: 0.91
Concepts Covered
LinearRegression, r2_score(), train-test evaluation.
Related Problems
- Problem 1: Calculate All Four Regression MetricsEasy · pythonSolve Problem
- Problem 2: Manually Calculate MAE and MSEEasy · pythonSolve Problem
- Problem 3: Compare MAE and RMSE with an OutlierEasy · pythonSolve Problem