Theory ofIntelligence
← PRACTICE/
Easy
Machine Learning• Loss & optimization

Implement mean squared error

Given two lists of predictions and targets (same length), compute the mean squared error: (1/n) * sum((pred[i] - target[i])^2).

Input: Two lines. First: space-separated predictions. Second: space-separated targets.

Output: One number (MSE), rounded to 4 decimal places.

Example:

  • Input: 1 2 3 and 1 2 4
  • Output: 0.3333 (only last element differs: (3-4)^2 = 1, mean = 1/3)
Sample Test Verification
2 Test Cases
Sample Input (stdin)
1 2 3
1 2 4
Expected Output (stdout)
0.3333
solution.py
Initializing Monaco Python Environment...
Input (stdin)
1 2 3 1 2 4
Expected Output (stdout)
0.3333