Python: запустить ARIMA в параллельной модели, результат не выдается - PullRequest
0 голосов
/ 02 марта 2019

Выполнение распараллеливания Модель ARIMA. Результат не выдается. Привет Все эксперты, я создал модель ARIMA с заказом (0,0,6) и запустил ее в параллельном режиме, чтобы обобщить ее к заказу (0,0,367). Здесьмой код:

enter code here
from matplotlib import pyplot
from statsmodels.tsa.arima_model import ARIMA
from sklearn.metrics import mean_squared_error
from statsmodels.graphics.tsaplots import plot_acf
from statsmodels.graphics.tsaplots import plot_pacf
from math import sqrt
import os
import multiprocessing as mp

 # step1 Order List Sections: Divide order into 3 sections each of which is 
 #a list of lenght 2
def divideOrderInList():
    pqOrderList = list()
    x = list()
    for i in range(1, 2 + 1):  # 1->2
    x.append(i)
    y = list()
    for i in range(2 + 1, 4 + 1):  # 3->4
        y.append(i)
    z = list()
    for i in range(4 + 1, 6 + 1):  # 5->6
        z.append(i)
    pqOrderList = (x, y, z)
    print(pqOrderList)
    return (pqOrderList)

    # step 2 : Create the 'modelfitFunc' function : this is the construction 
    #model function
def modelfitFunc(series, sectionOrder):
    expctd=series
    q1 = 0
    q2 = len(sectionOrder) - 1
    for q in (sectionOrder[q1], sectionOrder[q2]):
        arima_order = (0, 0, q)
        model = ARIMA(series, order=arima_order)
        results_MA = model.fit(disp=-1, start_params=[.1 for i in range(1 + 
                     arima_order[2])])
        yhatList = results_MA.fittedvalues
    residuals = [expctd[i] - yhatList[i] for i in range(len(expctd))]
    pyplot.figure()
    pyplot.subplot(211)  # 211
    plot_acf(residuals, ax=pyplot.gca(), lags=10)
    pyplot.subplot(212)  # 212
    plot_pacf(residuals, ax=pyplot.gca(), lags=10)
    pyplot.show()
    mse = mean_squared_error(expctd, yhatList)
    rmse = sqrt(mse)
    print(results_MA.summary())
    print(rmse)

# step 3 : Define 'funcThread' thread function
def modelfitFuncThread(series, listOrder):
    for sectionOrder in listOrder:
        modelfitFunc(series, sectionOrder

# step 4 : Define funcParallel : modelfitFuncParallel
def modelfitFuncParallel(series):
    if __name__ == "__main__":
        listOrder = divideOrderInList() #Result ([1, 2], [3, 4], [5, 6])
        nCPU = os.cpu_count()  # print(nCPU)  =8       exit()
        pool = mp.Pool(nCPU)
        results_MA = pool.apply(modelfitFuncThread, args=(series, 
                    listOrder)) 
        pool.close()
        pool.join()

# step 5 : Model ARIMA in parallel mode
def arima_Model_Static_PlotErrorAC_PAC(series, arima_order):
    results_MA = modelfitFuncParallel(series)
    return results_MA

        # step 6 : Call and Running Model ARIMA in parallel mode
series=[3.9, -1.4, 2.0, 3.4, 4.9, 1.792, 2.299, 0.6999, 1.5, 0.0, 1.19999, 
    5.4, 5.79, 3.5, 3.29, 3.0, 3.71, 3.1, -1.69993, -1.9004, -1.2001, 2.1, 
    3.201, -0.5, -2.8007, -4.9, -4.30002, -5.1, -1.0, 1.7008, 0.5,
    2.1, 1.0996, 2.896, 1.94, 1.307, -0.94, 2.58, -1.84, 0.693, -4.08, -2.0, 
    -0.799972, 0.599996, -1.9984, -0.386, -2.0, -3.396, -3.386, -2.0, 
 -4.899, -4.402, 1.0, -0.39986, 0.30007, 1.19999993, 2.197]

arima_order = (0, 0, 6)   
outputResidualError = arima_Model_Static_PlotErrorAC_PAC(series, 
arima_order) 

После этого я приступил к запуску своей модели и ждал больших времен (часов), пока не было выдано никаких ошибок, но я не получил никакого результата (просто пустая бегущая страница).Если кто-то может дать мне какое-либо предложение, чтобы получить желаемый результат, я буду благодарен С уважением

...