我正在使用 Facebook Prophet 按月预测一些时间序列数据。
ds y
2020-02-01 400.0
2020-03-01 450.0
2020-04-01 0.0
2020-05-01 225.0
我想使用 cross_validation() 函数来评估我的结果。
from fbprophet.diagnostics import cross_validation,performance_metrics
cv_results = cross_validation(
model = m,
initial = pd.to_timedelta(12,unit="M"),
horizon = pd.to_timedelta(12,unit="M"))
df_p = performance_metrics(cv_results)
但是我收到以下消息: ValueError:不再支持单位“M”和“Y”,因为它们不表示明确的时间增量值持续时间。
有人有解决方法吗?谢谢!
最佳答案
我认为 pandas 不再支持超过一天(“D”)的单位。 每当您对这些时间单位使用 pandas timedelta 时,就会出现此问题。
我建议使用天数并将 30 天乘以预期的月数
from fbprophet.diagnostics import cross_validation,performance_metrics
cv_results = cross_validation(
model = m,
initial = pd.to_timedelta(30*12,unit="D"),
horizon = pd.to_timedelta(30*12,unit="D"))
df_p = performance_metrics(cv_results)```
关于pandas - Facebook-Prophet 每月数据交叉验证 - 解决方法 : Pandas timedelta does not support Month and Years,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65197392/