本文整理汇总了Python中statsmodels.tsa.arima_model.ARIMA.predict方法的典型用法代码示例。如果您正苦于以下问题:Python ARIMA.predict方法的具体用法?Python ARIMA.predict怎么用?Python ARIMA.predict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类statsmodels.tsa.arima_model.ARIMA
的用法示例。
在下文中一共展示了ARIMA.predict方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_arima_predictions
# 需要导入模块: from statsmodels.tsa.arima_model import ARIMA [as 别名]
# 或者: from statsmodels.tsa.arima_model.ARIMA import predict [as 别名]
def get_arima_predictions(y, train_subset, order = [1,0,0], X = None):
if X == None:
arima = ARIMA(y[train_subset], order = order).fit()
predictions = arima.predict()
else:
arima = ARIMA(y[train_subset], order = order,
exog = X[train_subset,:]).fit()
predictions = arima.predict(exog = X[train_subset,:])
for i in range(max(train_subset)+1,len(y)):
if X == None:
arima = ARIMA(y[0:i], order = order).fit()
predictions = np.append(predictions,
arima.predict(0, len(y) + i)[-1])
else:
arima = ARIMA(y[0:i], order = order, exog = X[0:i,:]).fit()
predictions = np.append(predictions,
arima.predict(0, len(y) + i,
exog = X[0:i+1,:])[-1])
return predictions
示例2: programmer_5
# 需要导入模块: from statsmodels.tsa.arima_model import ARIMA [as 别名]
# 或者: from statsmodels.tsa.arima_model.ARIMA import predict [as 别名]
def programmer_5():
discfile = "data/discdata_processed.xls"
# 残差延迟个数
lagnum = 12
data = pd.read_excel(discfile, index_col="COLLECTTIME")
data = data.iloc[:len(data) - 5]
xdata = data["CWXT_DB:184:D:\\"]
# 训练模型并预测,计算残差
arima = ARIMA(xdata, (0, 1, 1)).fit()
xdata_pred = arima.predict(typ="levels")
pred_error = (xdata_pred - xdata).dropna()
lb, p = acorr_ljungbox(pred_error, lags=lagnum)
h = (p < 0.05).sum()
if h > 0:
print(u"模型ARIMA(0,1,1)不符合白噪声检验")
else:
print(u"模型ARIMA(0,1,1)符合白噪声检验")
print(lb)
示例3: get_feature_by_day
# 需要导入模块: from statsmodels.tsa.arima_model import ARIMA [as 别名]
# 或者: from statsmodels.tsa.arima_model.ARIMA import predict [as 别名]
ax = feature_indiv.plot(y='value',use_index=True)
if feature == 'mood':
ax.set_ylim((0,10))
ax.set_xlim((min(feature_indiv.index),max(feature_indiv.index)))
fig = ax.get_figure()
plt.show(block=False)
plt.close(fig)
for individual in indiv_ids:
print individual
#plot_histogram(individual, 'mood')
#plot_series(individual, 'mood')
#%%
y = get_feature_by_day(feature, current_indiv).values
train_subset = range(30)
arima = ARIMA(y[train_subset], [1,0,0]).fit()
predictions = arima.predict()
for i in range(max(train_subset)+1,len(y)):
arima = ARIMA(y[0:i], [1,0,0]).fit()
predictions = np.append(predictions,arima.predict(0, len(y) + i)[-1])
y = get_feature_by_day(feature, current_indiv)
y['preds'] = predictions
y.plot()
rmse(y['preds'].values,y['value'].values)
#%%
arima.predict(start = min(y.index), end = 50)
#%%
from statsmodels.tsa.stattools import acf, pacf
def get_feature_by_day(feature, current_indiv):
y = get_feature(feature, current_indiv)
avg_features = ['mood', 'circumplex.valence', 'circumplex.arousal']
sum_features = [s for s in feature_names if s not in avg_features]
示例4: len
# 需要导入模块: from statsmodels.tsa.arima_model import ARIMA [as 别名]
# 或者: from statsmodels.tsa.arima_model.ARIMA import predict [as 别名]
# -*- coding: utf-8 -*-
# 模型检验
import pandas as pd
# 参数初始化
discfile = '../data/discdata_processed.xls'
lagnum = 12 # 残差延迟个数
data = pd.read_excel(discfile, index_col='COLLECTTIME')
data = data.iloc[: len(data) - 5] # 不使用最后5个数据
xdata = data['CWXT_DB:184:D:\\']
from statsmodels.tsa.arima_model import ARIMA # 建立ARIMA(0,1,1)模型
arima = ARIMA(xdata, (0, 1, 1)).fit() # 建立并训练模型
xdata_pred = arima.predict(typ='levels') # 预测
print "-------預測模型------------\n", xdata_pred
pred_error = (xdata_pred - xdata).dropna() # 计算残差
from statsmodels.stats.diagnostic import acorr_ljungbox # 白噪声检验
lb, p = acorr_ljungbox(pred_error, lags=lagnum)
h = (p < 0.05).sum() # p值小于0.05,认为是非白噪声。
if h > 0:
print(u'模型ARIMA(0,1,1)不符合白噪声检验')
else:
print(u'模型ARIMA(0,1,1)符合白噪声检验')