我是时间序列分析的新手,我目前正在尝试根据前几周这些用户的行驶里程来预测某些用户的行驶里程。对于我的数据集中的每个用户和数千个用户,我有4英里的值(4周中某星期几的值)。
数据看起来像这样
Name Miles_covered Date
John 525 07/07/2019
John 300 09/06/2019
John 200 12/05/2019
John 400 14/04/2019
Maria 12 07/07/2019
Maria 15 09/06/2019
Maria 16 12/05/2019
Maria 80 14/04/2019
Raj 52 07/07/2019
Raj 68 09/06/2019
Raj 90 12/05/2019
Raj 4 14/04/2019
我使用在网上找到的python脚本对数据进行了初步分析,但是我不确定如何结合这样的事实,即预测将分别针对每个用户(ts是我的日期列的系列对象)。
是否可以对此类数据进行时间序列预测分析?还是需要使用其他方法?
def test_stationarity(timeseries):
#Determing rolling statistics
rolmean = ts.rolling(1).mean()
rolstd = ts.rolling(1).std()
#Plot rolling statistics:
orig = plt.plot(timeseries, color='blue',label='Original')
mean = plt.plot(rolmean, color='red', label='Rolling Mean')
std = plt.plot(rolstd, color='black', label = 'Rolling Std')
plt.legend(loc='best')
plt.title('Rolling Mean & Standard Deviation')
plt.show(block=False)
#Perform Dickey-Fuller test:
print ('Results of Dickey-Fuller Test:')
dftest = adfuller(timeseries, autolag='AIC')
dfoutput = pd.Series(dftest[0:4], index=['Test Statistic','p-value','#Lags Used','Number of Observations Used'])
for key,value in dftest[4].items():
dfoutput['Critical Value (%s)'%key] = value
print (dfoutput)