Skip to content
CampusEduX

Problem 1: Calculate All Four Regression Metrics

Easypython
Learn the Concept: Regression Metrics (MAE, MSE, RMSE, R²)

Problem Description

Write a Python program that calculates MAE, MSE, RMSE, and R² for a set of actual and predicted values using Scikit-learn.

Input

Two lists: actual values and predicted values.

Output

All four calculated metrics.

Constraints

  • Both lists must have the same length.

Example Input

text
actual=[100,150,200,250], predicted=[110,140,210,240]

Example Output

text
MAE: 10.0 MSE: 100.0 RMSE: 10.0 R² Score: 0.98...

Concepts Covered

mean_absolute_error(), mean_squared_error(), r2_score(), np.sqrt().

Related Problems

  • Problem 2: Manually Calculate MAE and MSE
    Easy · python
    Solve Problem
  • Problem 3: Compare MAE and RMSE with an Outlier
    Easy · python
    Solve Problem
  • Problem 4: Calculate R² for a Trained Regression Model
    Easy · python
    Solve Problem

Input (stdin)

Output

Run your code to see output here...