python - ARIMA 模型预测的订购时间戳
问题描述
信息:
我正在尝试预测比特币的价格,作为测试并使其更容易,在我的数据中我最近的日期时间后 1 天。所以 t = 2020 年 5 月 27 日,t + 1 = 2020 年 5 月 28 日。
所以我加载了我的数据:
x = pd.read_csv('btcdata.csv', header=0, parse_dates=['Date'], index_col=0)
close = x.Close
这就是它的样子.head()
:
Date
2020-05-27 8854.32
2020-05-26 8844.42
2020-05-25 8899.31
2020-05-24 8715.73
2020-05-23 9181.76
这有一个小问题,最近的日期位于顶部,最旧的日期位于底部。大多数日期都是按相反的方式组织的,至少 ARIMA 模型是这样看待它的。
因此,当我使用该模型进行拟合和预测时.forecast()
,这是我的output[0]
:
[381.59648517]
这实际上与.tail()
我的数据更匹配:
Date
2014-12-05 377.1
2014-12-04 377.1
2014-12-03 378.0
2014-12-02 378.0
2014-12-01 370.0
问题/问题:
我该如何解决这个问题,并以某种方式对其进行排序,以便 ARIMA 模型知道哪个是我最近的日期t
并知道预测t + 1
同样,每次我适合我的模型时,都会出现这两个警告。它可能与问题有关:
ValueWarning: A date index has been provided, but it has no associated frequency information and so will be ignored when e.g. forecasting.
ValueWarning: A date index has been provided, but it is not monotonic and so will be ignored when e.g. forecasting.
解决方案
ValueWarning: A date index has been provided, but it has no associated frequency information and so will be ignored when e.g. forecasting.
表示 ARIMA 不了解您的数据格式。
这应该将所有内容转换为 DatetimeIndex,频率为天。
x.index = pd.DatetimeIndex(x.index).to_period('D')
ValueWarning: A date index has been provided, but it is not monotonic and so will be ignored when e.g. forecasting.
表示数据未排序,因此输入以下行:
x = x.sort_index()
推荐阅读
- angular - Angular 6 - 在构建中不包括共享组件
- inno-setup - Inno Setup - 如何识别源目录的 USB 驱动器
- apache-spark - 在 Databricks 中从 UDF 内部查询 Delta Lake
- ssl - Keycloak 独立 HTTPS 配置引发错误,提示在密钥库中找不到密钥
- regex - 正则表达式:某个地方的某个数字
- javascript - 在 JS 中,console.log 以不同的方式运行,如代码所示。为什么?
- python - ValueError:无法为具有形状“(?,6)”的张量“Placeholder_3:0”提供形状(0、0)的值
- node.js - 在 netlify 本地创建 markdown 文件
- reactjs - 在 gitlab CI/CD 管道中自动检查许可证
- ios - 颜色未正确设置为搜索栏