Mean Squared Error
2026/3/9小于 1 分钟
Mean Squared Error
题面
实现均方误差(MSE)计算:对等长 predictions 与 targets,计算 MSE = (1/N) Σ (pred_i - targ_i)^2。
Implementation Requirements
- External libraries are not permitted.
- The solve function signature must remain unchanged.
- The final result must be stored in the
mse变量。
Examples
predictions = [1.0, 2.0, 3.0, 4.0], targets = [1.5, 2.5, 3.5, 4.5] → mse = 0.25
predictions = [10.0, 20.0, 30.0], targets = [12.0, 18.0, 33.0] → mse = 5.67Constraints
- 1 ≤ N ≤ 100,000,000
- -1000.0 ≤ predictions[i], targets[i] ≤ 1000.0
- Performance is measured with N = 50,000,000