MSE Practice Problem
This data science coding problem helps you practice Evaluation Metrics, mse, and implementation skills. Read the problem statement, write your solution, and strengthen your understanding of Evaluation Metrics.
- Problem ID: 17
- Problem key: 17-mse
- URL: https://datacrack.app/solve/17-mse
- Difficulty: easy
- Topic: Evaluation Metrics
- Module: Introduction to Machine Learning
Problem Statement
## 🧩 Compare Models Using MSE
### 🎯 Goal
Evaluate and compare **two regression models** using Mean Squared Error.
---
### 📥 Input / 📤 Output
**Input**
- `y_true` (`list[float]`): true target values
- `y_pred_a` (`list[float]`): predictions from **Model A**
- `y_pred_b` (`list[float]`): predictions from **Model B**
**Output**
* `int`
* return `0` if **Model A** is better
* return `1` if **Model B** is better
* return `-1` if they are equal
(Better = lower MSE)
---
### 💻 Task Description
1. Compute the MSE for both models
2. Compare their errors
3. Return which model performs better
This problem is **evaluation only** — models are already trained.
---
### 🧩 Starter Code
```python
import numpy as np
def better_model_mse(y_true, y_pred_a, y_pred_b):
"""
Returns:
0 if Model A is better
1 if Model B is better
-1 if equal
"""
pass
```
---
### 💡 Example
```python
y_true = [3, -1, 2]
y_pred_a = [2, 0, 2]
y_pred_b = [3, -1, 1]
better_model_mse(y_true, y_pred_a, y_pred_b)
```
**Expected Output**
```
1
```
---
Starter Code
import numpy as np
def better_model_mse(y_true, y_pred_a, y_pred_b):
"""
Returns:
0 if Model A is better
1 if Model B is better
-1 if equal
"""
pass