current position:Home>Python uses ARIMA and arimax to predict the time series data of store commodity sales demand

Python uses ARIMA and arimax to predict the time series data of store commodity sales demand

2022-06-24 08:56:23Extension Research Office

Link to the original text :http://tecdat.cn/?p=27363 

The source of the original text is : The official account of the tribal public

 

This paper explores different time series techniques on relatively simple data sets .

Given 5 Store sales data for , And ask you to predict 10 From different stores 50 Different products in 3 Sales within months .

What is the best way to deal with seasonality ? The store should be modeled separately , They can still be combined ?

Store project demand forecast

Autoregressive composite moving average (ARIMA)

this  ARIMA  The model can be applied to nonstationary time series ARMA Generalization of the model .

import time
import pandas as pd

%matplotlib inline

Load data

d_trn = pd.rad_csv('../inuraicsv, prse_tes=date'], inx_col['te'])
d_ts = pd.ra_csv'../iputst.csv', prse_des=['date'], ine_col['d

All stores seem to show the same trend and seasonality .

ARIMAX

Autoregressive composite moving average with explanatory variables (ARIMAX) yes ARIMA Extended version of , These include independent predictors .

Prepare the data

mnths = df_rinindx.nth

df_ran.drpna(iplac=True)
d_trin.head()

import datetime

dumymns = pd.get_dummies(moth)

prev_uate_dates = d_tet_x.index - datie.timedelta(das=91)
dfetex.head()

Build the model

si1 = d_rin.loc[(d_tin['store'] == 1) & (_tran['ie'] == 1), 'ses']
exog_s1i1 = df_train.loc[(df_train['store'] == 1) & (df_train['item'] == 


ax = SARIMAX(si1.loc['2013-12-31':], exog=exog
                                   nfoceinvetiblity=alse,enforce_ationarity=False, 

Make predictions


        nog = df_rai.loc[(ftrin['str'] == s) & (df_rin['te'] == i), 'als']
        
        SARIMAX(endog=edog exog=xo,
                                           enorce_invtiilit=False, eorce_statnarityFalse, freq='D',
                                           order=(7,0,0)).fit()
       
        tc = time.time()

Example forecast

xg = f_rin.loc[(df_rin[ste'] == 10) & (d_tri['itm'] == 50)].drop(['', 'ite', 'sas'], axis=1)
forast = arax.predict


The most popular insights

1. stay python Use in lstm and pytorch Make time series predictions

2.python Using the short-term and long-term memory model lstm Time series prediction analysis

3.Python use RNN Cyclic neural network :LSTM Long term memory 、GRU Gate cycle unit 、 Regression and ARIMA Yes COVID-19 The time series of the new population of COVID-19

4.Python TensorFlow Cyclic neural network RNN-LSTM Neural network predicts the time series of stock market price and MSE Assess accuracy

5.r Language copulas And financial time series cases

6.R Language use RNN Cyclic neural network 、LSTM The long-term and short-term memory network realizes the prediction of long-term interest rate in time series

7.Matlab Create vector autoregressive (VAR) Model analysis of consumer price index (CPI) And unemployment time series

8.r Language k-shape Time series clustering method for stock price time series clustering

9.R Language combined with COVID-19 COVID-19 Stock price forecast :ARIMA,KNN And neural network time series analysis

copyright notice
author[Extension Research Office],Please bring the original link to reprint, thank you.
https://en.pythonmana.com/2022/175/202206240706580447.html

Random recommended