當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。