如何使用 ARIMA 模型来预测多列数据帧中的事件

发布于 2025-01-18 07:04:11 字数 407 浏览 4 评论 0原文

https://docs.google.com/spreadsheets/d/1JmMoGcKI9ycFkYi0lrqtnb0sj2JKmJ1l/edit?usp=sharing&rtpof=true&sd=true

该数据集包含一个月内进入火车站的乘客数量。每列编号1-74是5:30-24:00之间15分钟的时间间隔。并记录每天每个时间段的乘客总数。 我想使用前 28 天的数据创建 arima 模型,并使用它来预测第 29 天的数据。 我要得到 p、d &每个时间间隔(即每列)的 q 值,并将其用于模型创建,总共产生 74 个预测。还可以选择整列并计算 p、d 和 p、d。用于所有其他列的值。

我是 ARIMA 新手,我什至不知道如何完成这项任务。

https://docs.google.com/spreadsheets/d/1JmMoGcKI9ycFkYi0lrqtnb0sj2JKmJ1l/edit?usp=sharing&rtpof=true&sd=true

The dataset contains number of passenger entering a train station in a month. Each column numbered 1-74 are time intervals of 15minutes from 5:30 - 24:00. And the total number of passengers for each timee period every day is recorded.
I want to use the data for the first 28 day to create the arima model and use that to predict the data for the 29th day.
I am to get p, d & q value for each time interval(i.e each column) and use it for model creation resulting on 74 total predictions. Can also select a entire column and calculate the p, d & value to be used for all other columns.

I am new to ARIMA and i dont even know how to go about with this task.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

玩套路吗 2025-01-25 07:04:11

您可以使用 statsmodels ARIMA 实现。您可以使用前 28 个观测值为每个时间片训练一个单独的 ARIMA 模型。

import pandas as pd
from statsmodels.tsa.arima_model import ARIMA

df = pd.read_csv("inbound_flights.csv")
df.drop(columns=['Unnamed: 0'], inplace=True)

# use first rows for training and use last row for out-of-sample testing
X_train, X_test = df.iloc[:-1, :], df.iloc[[-1],:]

order = (5,1,0) # <- plug-in p, d, q here

for col in X_train.columns:
  # fit model
  model = ARIMA(X_train[col], order=order)
  model_fit = model.fit()

  # summary of fit model
  #print(model_fit.summary())

  # make one-day forecast
  forecast, _, _ = model_fit.forecast(steps=1)
  print(forecast[0])

You can use statsmodels ARIMA implementation. You train a separate ARIMA model for every time slice using the first 28 observations.

import pandas as pd
from statsmodels.tsa.arima_model import ARIMA

df = pd.read_csv("inbound_flights.csv")
df.drop(columns=['Unnamed: 0'], inplace=True)

# use first rows for training and use last row for out-of-sample testing
X_train, X_test = df.iloc[:-1, :], df.iloc[[-1],:]

order = (5,1,0) # <- plug-in p, d, q here

for col in X_train.columns:
  # fit model
  model = ARIMA(X_train[col], order=order)
  model_fit = model.fit()

  # summary of fit model
  #print(model_fit.summary())

  # make one-day forecast
  forecast, _, _ = model_fit.forecast(steps=1)
  print(forecast[0])
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文