当我从预测值中减去真值时,我得到了 NaN 值。我不明白为什么这不起作用。这是我的代码和下面的输出。输出显示无法减去这些值,但我不知道为什么。
mte_forecast = pred.predicted_mean
print(mte_forecast)
mte_truth = mte.loc['2003-07-01':]
print(mte_truth)
# Compute the mean square error
mse = ((mte_forecast - mte_truth) ** 2).mean()
print(mse)
Here is the output I get:
2003-07-01 33.152466
2003-08-01 35.986610
2003-09-01 28.641228
2003-10-01 21.268629
2003-11-01 17.953365
...
2016-03-01 39.184456
2016-04-01 39.275757
2016-05-01 43.132015
2016-06-01 49.973976
2016-07-01 61.067493
Freq: MS, Name: predicted_mean, Length: 157, dtype: float32
emissions
dates
2003-07-01 34.139999
2003-08-01 37.020000
2003-09-01 25.382000
2003-10-01 22.150000
2003-11-01 18.858000
... ...
2016-03-01 40.525002
2016-04-01 39.763000
2016-05-01 44.209999
2016-06-01 53.567001
2016-07-01 62.881001
[157 rows x 1 columns]
2003-07-01 00:00:00 NaN
2003-08-01 00:00:00 NaN
2003-09-01 00:00:00 NaN
2003-10-01 00:00:00 NaN
2003-11-01 00:00:00 NaN
..
2016-04-01 00:00:00 NaN
2016-05-01 00:00:00 NaN
2016-06-01 00:00:00 NaN
2016-07-01 00:00:00 NaN
emissions NaN
Length: 158, dtype: float64