当前位置: 首页>>代码示例>>Python>>正文


Python ARIMA.predict方法代码示例

本文整理汇总了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
开发者ID:MBleeker,项目名称:Data-Mining,代码行数:21,代码来源:script_liam3.py

示例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)
开发者ID:Ctipsy,项目名称:python_data_analysis_and_mining_action,代码行数:23,代码来源:code.py

示例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]
开发者ID:MBleeker,项目名称:Data-Mining,代码行数:33,代码来源:script_liam3.py

示例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)符合白噪声检验')
开发者ID:kriloc,项目名称:pythonExamples,代码行数:31,代码来源:arima_model_check.py


注:本文中的statsmodels.tsa.arima_model.ARIMA.predict方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。