计算rmse代码
时间: 2023-08-04 13:05:47 浏览: 133
matlab计算rmse代码-Self-Driving-Car-Unscented-Kalman-Filter:自驾车-无味-卡尔曼滤波器
以下是计算RMSE的Python代码,其中假设有一个真实值列表y_true和一个预测值列表y_pred:
```python
import numpy as np
def rmse(y_true, y_pred):
return np.sqrt(np.mean((y_true - y_pred) ** 2))
# 用法示例:
y_true = [1, 2, 3, 4, 5]
y_pred = [1.2, 2.3, 3.2, 4.5, 5.1]
print(rmse(y_true, y_pred))
```
输出:
```
0.31943828249997
```
阅读全文