[공모전 수상작 리뷰] Reactjs+Nodejs+python+scikit-learn{ PCA(주성분 분석), VAR(다변량시계열분석)}으로 공연 예매 추이 시나리오 별 예측하는 서비스 만들어보기 - 데이터 분석 편(3)

확정 모델(m9)로 직접 공연 예매 건수 예측해보기

기본적인 피처 설명

기간: 2019.01.01 ~ 2021.08.31

  • ott_user_count: OTT앱 일 별 사용자 수,

  • ott_usage_time: OTT앱 일 별 사용시간,

  • delivery_user_count: 배달앱 일 별 사용자 수,

  • delivery_usage_time: 배달앱 일 별 사용시간,

  • used_user_count: 중고거래앱 일 별 사용자 수,

  • used_usage_time: 중고거래앱 일 별 사용시간,

  • meeting_user_count: 화상회의앱 일 별 사용자 수,

  • meeting_usage_time: 화상회의앱 일 별 사용시간,

  • corona_count: 일 별 코로나 확진자 수,

  • subway_count: 일 별 지하철 이용자 수,

  • KOSPI_index: 일 별 코스피 지수,

  • KOSPI_trading: 일 별 코스피 시장 거래량,

  • KOSDAQ_index: 일 별 코스닥 지수,

  • KOSDAQ_trading: 일 별 코스닥 시장 거래량,

  • coin_trading: 일 별 가상화폐(비트코인+이더리움)거래량 평균,

  • coin_variance: 전 일 대비 일 별 가상화폐(비트코인+이더리움)등락률 평균,

#필요 라이브러리 로드
import numpy as np
import pandas as pd
import seaborn as sns
from statsmodels.stats.outliers_influence import variance_inflation_factor
import matplotlib.pyplot as plt
import matplotlib.font_manager as fm
import matplotlib
matplotlib.font_manager._rebuild()
from sklearn.preprocessing import StandardScaler, MinMaxScaler, RobustScaler,Normalizer
from sklearn.preprocessing import OneHotEncoder, LabelEncoder

from sklearn.model_selection import train_test_split

from sklearn.metrics import mean_squared_error, r2_score

from sklearn.decomposition import PCA

from statsmodels.tsa.api import VAR
from statsmodels.tsa.stattools import adfuller

sns.set(style='whitegrid')
pd.set_option('display.max_rows',500)
font_path = r'경로\\NanumFontSetup_TTF_GOTHIC.NanumGothic.ttf'
fontprop = fm.FontProperties(fname=font_path, size=18)

데이터 로드 및 기초 전처리

#데이터 로드 및 기초 전처리
df = pd.read_csv("저장링크\\201901_202108_종합통계_시계열분석용.csv")
df.drop('Unnamed: 0', axis=1, inplace=True)
df['corona_count'].fillna(0,inplace=True)
df['coin_trading'] = df['bitcoin_trading']+df['ethereum_trading']
df['coin_variance'] = (df['bitcoin_variance']+df['ethereum_variance'])/2
df.drop(['bitcoin_trading','ethereum_trading',
        'bitcoin_variance','ethereum_variance'],axis=1,inplace=True)
df.index = df['date']
df_date = df['date']
df.drop(['date'],axis=1, inplace=True)

타겟,피처 분리 및 스탠다드스케일링 수행

X = df.iloc[:,1:]
y = df.iloc[:,0]
#StandardScaler 객체 생성
scaler = StandardScaler()
#StandardScaler로 데이터 셋 변환, fit()과 transform()호출
scaler.fit(X)
X_scaled = scaler.transform(X)
X_scaled = pd.DataFrame(data=X_scaled, columns=X.columns)
X_scaled.index = df_date
X_scaled
ott_user_count ott_usage_time delivery_user_count delivery_usage_time used_user_count used_usage_time meeting_user_count meeting_usage_time corona_count subway_count KOSPI_index KOSPI_trading KOSDAQ_index KOSDAQ_trading coin_trading coin_variance
date
2019/01/01 -1.301964 -1.126337 -1.138730 -0.879145 -1.332576 -1.373703 -1.053405 -0.843484 -0.607122 -1.546825 -0.857302 -1.152997 -0.801456 -1.333287 -0.760446 0.894595
2019/01/02 -1.411287 -1.360638 -1.542213 -1.360824 -1.294828 -1.363849 -0.816423 -0.804730 -0.607122 0.758960 -0.857302 -1.152997 -0.801456 -1.333287 -0.473632 1.209898
2019/01/03 -1.512255 -1.380048 -1.536694 -1.377820 -1.179579 -1.346215 -0.813926 -0.802878 -0.607122 0.908731 -0.892203 -0.903009 -0.886813 -1.155502 -0.653263 -0.830298
2019/01/04 -1.343318 -1.318085 -1.434606 -1.294248 -1.309262 -1.362754 -0.819952 -0.804077 -0.607122 1.091537 -0.856767 -0.947702 -0.835184 -1.310455 -0.547525 0.442506
2019/01/05 -1.010367 -0.963209 -1.174507 -0.999621 -1.319738 -1.330514 -1.046767 -0.836480 -0.607122 -0.153104 -0.856767 -0.947702 -0.835184 -1.310455 -0.557694 -0.100001
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2021/08/27 1.656060 1.539082 2.271937 2.151560 1.174091 0.778091 1.484776 1.743173 3.594865 1.533985 1.549169 -0.705340 1.646165 -0.178085 -1.055345 1.133390
2021/08/28 1.780755 1.632663 2.442208 2.699594 1.484143 1.128198 -0.075720 0.000089 3.187087 -0.002058 1.549169 -0.705340 1.646165 -0.178085 -1.100312 -0.239105
2021/08/29 1.692069 2.029458 2.325626 2.782625 1.308575 1.197393 0.060223 0.137999 2.877739 -0.921063 1.549169 -0.705340 1.646165 -0.178085 -1.079082 -0.199692
2021/08/30 1.312763 1.266002 1.502044 1.133586 1.316112 0.847673 1.702709 1.957982 2.608230 1.558606 1.571202 -0.509248 1.703738 -0.361816 -1.041119 -0.505722
2021/08/31 1.434144 1.282830 1.685858 1.606643 1.279019 0.879251 1.712669 1.997506 4.138569 1.394636 1.689138 -0.386843 1.748593 -0.262413 -0.977654 0.676665

974 rows × 16 columns

변수 2개로 PCA 수행

pca = PCA(n_components=2)
printcipalComponents = pca.fit_transform(X_scaled)
principalDf = pd.DataFrame(data=printcipalComponents, columns = ['p1','p2'])
print(principalDf.head())
print(pca.explained_variance_ratio_)
print(sum(pca.explained_variance_ratio_))
         p1        p2
0 -3.472938  0.264457
1 -4.064765 -1.172083
2 -4.014694 -1.128189
3 -3.982567 -1.288346
4 -3.529418 -0.322702
[0.63059992 0.10080491]
0.7314048320656544
principalDf.index = df_date
principalDf
p1 p2
date
2019/01/01 -3.472938 0.264457
2019/01/02 -4.064765 -1.172083
2019/01/03 -4.014694 -1.128189
2019/01/04 -3.982567 -1.288346
2019/01/05 -3.529418 -0.322702
... ... ...
2021/08/27 5.117077 -3.194164
2021/08/28 4.866254 -1.415963
2021/08/29 5.011647 -0.716045
2021/08/30 4.346513 -3.065882
2021/08/31 5.077023 -3.389693

974 rows × 2 columns

df=principalDf
principalDf.index = df_date
df = pd.merge(y, principalDf,left_index=True, right_index=True,how='inner')
df
ticketing_count p1 p2
date
2019/01/01 7401 -3.472938 0.264457
2019/01/02 5069 -4.064765 -1.172083
2019/01/03 6498 -4.014694 -1.128189
2019/01/04 7088 -3.982567 -1.288346
2019/01/05 18755 -3.529418 -0.322702
... ... ... ...
2021/08/27 19582 5.117077 -3.194164
2021/08/28 45456 4.866254 -1.415963
2021/08/29 31871 5.011647 -0.716045
2021/08/30 3652 4.346513 -3.065882
2021/08/31 8582 5.077023 -3.389693

974 rows × 3 columns

정상성확인

for i in df.columns:
    adfuller_test = adfuller(df[i],autolag='AIC')
    print(i)
    print("ADF test statistic: {}".format(adfuller_test[0]))
    print("p-value: {}".format(adfuller_test[1]))
    
df_diff = df.diff().dropna()

df_diff.plot(figsize=(20,20))
print(df_diff)
for i in df.columns:
    adfuller_test = adfuller(df_diff[i],autolag='AIC')
    print(i)
    print("ADF test statistic: {}".format(adfuller_test[0]))
    print("p-value: {}".format(adfuller_test[1]))
train = df_diff.iloc[:-30,:]
test = df_diff.iloc[-30:,:]
print(train, test)

forecasting_model = VAR(train)
results_aic = []
for p in range(1,30):
  results = forecasting_model.fit(p)
  results_aic.append(results.aic)

sns.set()
plt.plot(list(np.arange(1,30,1)), results_aic)
plt.xlabel("Order")
plt.ylabel("AIC")
plt.show()

for i in results_aic:
    print(i)
print("최적순서")
print(np.argsort(results_aic)[0])
print(results_aic[np.argsort(results_aic)[0]])
results = forecasting_model.fit(np.argsort(results_aic)[0])
results.summary()

laaged_values = train.values
forecast = pd.DataFrame(results.forecast(y= laaged_values, steps=30), index = test.index,\
                        columns=df.columns)

for i in df.columns:
    forecast[f'{i}_forecasted']= df[i].iloc[-30-1]+forecast[i].cumsum()
print(forecast)

test = df.iloc[-30:,:1]
for i in test.columns:
    test[f'{i}_forecasted'] = forecast[f'{i}_forecasted']
test.plot(figsize=(20,20))

mse = mean_squared_error(test['ticketing_count'], test['ticketing_count_forecasted'])
rmse = np.sqrt(mse)

print(f'MSE: {mse}')
print(f'RMSE: {rmse}')
print('Variance score: {0:.3f}'.format(r2_score(test['ticketing_count'],
                                                test['ticketing_count_forecasted'])))

# for i in range(3):
#     test = df.iloc[-30:,i:i+1]
#     for i in test.columns:
#         test[f'{i}_forecasted'] = forecast[f'{i}_forecasted']
#     test.plot(figsize=(20,20))
ticketing_count
ADF test statistic: -2.099553733500803
p-value: 0.24469408536639126
p1
ADF test statistic: -0.21267008715649313
p-value: 0.9369944290578626
p2
ADF test statistic: -0.9660338259001354
p-value: 0.7654502757577035
            ticketing_count        p1        p2
date                                           
2019/01/02          -2332.0 -0.591827 -1.436540
2019/01/03           1429.0  0.050071  0.043894
2019/01/04            590.0  0.032127 -0.160157
2019/01/05          11667.0  0.453149  0.965645
2019/01/06          -5564.0  0.215044  0.535168
...                     ...       ...       ...
2021/08/27           3970.0  0.335959  0.163582
2021/08/28          25874.0 -0.250823  1.778201
2021/08/29         -13585.0  0.145392  0.699918
2021/08/30         -28219.0 -0.665134 -2.349837
2021/08/31           4930.0  0.730510 -0.323811

[973 rows x 3 columns]
ticketing_count
ADF test statistic: -8.90366524755091
p-value: 1.1532103667357817e-14
p1
ADF test statistic: -7.316333641273258
p-value: 1.2265309593054393e-10
p2
ADF test statistic: -8.654863167499396
p-value: 5.0006128672818535e-14
            ticketing_count        p1        p2
date                                           
2019/01/02          -2332.0 -0.591827 -1.436540
2019/01/03           1429.0  0.050071  0.043894
2019/01/04            590.0  0.032127 -0.160157
2019/01/05          11667.0  0.453149  0.965645
2019/01/06          -5564.0  0.215044  0.535168
...                     ...       ...       ...
2021/07/28           7195.0  0.271976 -0.397341
2021/07/29          -1568.0  0.121974  0.071939
2021/07/30           1240.0 -0.323097 -0.009642
2021/07/31          11692.0  0.806326  1.693124
2021/08/01          -1419.0 -0.083921  0.568040

[943 rows x 3 columns]             ticketing_count        p1        p2
date                                           
2021/08/02         -23309.0 -1.197897 -1.823121
2021/08/03           6021.0  0.382762 -0.307690
2021/08/04           5184.0  0.224371 -0.159779
2021/08/05          -1820.0  0.213700  0.045172
2021/08/06           2199.0  0.210503  0.053557
2021/08/07          15793.0  0.433313  1.324466
2021/08/08          -6053.0  0.227528  0.915187
2021/08/09         -22049.0 -1.476812 -2.419552
2021/08/10           4498.0  0.864029 -0.313854
2021/08/11           5951.0 -0.361891  0.011769
2021/08/12          -1827.0 -0.178059 -0.032996
2021/08/13           5810.0  0.349272  0.207221
2021/08/14          14591.0  0.313612  1.626783
2021/08/15          -7036.0 -0.030712  0.621387
2021/08/16         -18277.0 -0.492023 -0.229886
2021/08/17           1743.0 -0.320392 -2.102970
2021/08/18          10810.0  0.231022 -0.418104
2021/08/19          -3599.0  0.186924  0.148053
2021/08/20           1624.0  0.140931  0.255090
2021/08/21          24481.0  0.576043  2.264528
2021/08/22          -9835.0 -0.445505  0.305457
2021/08/23         -28924.0 -0.563361 -2.491265
2021/08/24           9165.0  0.635171 -0.388304
2021/08/25           9759.0 -0.326547 -0.162770
2021/08/26          -7134.0  0.101249  0.099862
2021/08/27           3970.0  0.335959  0.163582
2021/08/28          25874.0 -0.250823  1.778201
2021/08/29         -13585.0  0.145392  0.699918
2021/08/30         -28219.0 -0.665134 -2.349837
2021/08/31           4930.0  0.730510 -0.323811


C:\Users\USER\anaconda3\lib\site-packages\statsmodels\tsa\base\tsa_model.py:162: ValueWarning: No frequency information was provided, so inferred frequency D will be used.
  % freq, ValueWarning)

15.874141457581395
15.5563271912253
15.426246152939317
15.318750926870058
14.483015895965174
13.814739596824277
13.673927483926283
13.665937798337964
13.663878431792096
13.676651939760099
13.692038994826223
13.677564677917928
13.52434197981419
13.490367614527221
13.499927178777222
13.512585794850738
13.529358365994831
13.542355918442388
13.539247800974483
13.496007805199893
13.470538807423434
13.488222723432752
13.499948384661002
13.511730951232966
13.521836126222121
13.538180085837523
13.521278819452538
13.51962317725291
13.531074509808017
최적순서
20
13.470538807423434
            ticketing_count        p1        p2  ticketing_count_forecasted  \
date                                                                          
2021/08/02    -21642.828430 -1.033055 -1.920281                 6203.171570   
2021/08/03      4108.724575  0.139701 -0.231206                10311.896145   
2021/08/04      6880.360833  0.272476 -0.069083                17192.256978   
2021/08/05     -2316.669341  0.105379 -0.046469                14875.587637   
2021/08/06      3700.776692  0.056802  0.183212                18576.364329   
2021/08/07     15584.686419  0.523810  1.435338                34161.050747   
2021/08/08     -7120.885435  0.155960  0.662741                27040.165312   
2021/08/09    -21598.560364 -1.056706 -1.925830                 5441.604948   
2021/08/10      6374.681052  0.093848 -0.235443                11816.286001   
2021/08/11      4835.465688  0.167524  0.017505                16651.751688   
2021/08/12     -1061.610712  0.108480 -0.038615                15590.140976   
2021/08/13      3194.224752  0.057892  0.030914                18784.365728   
2021/08/14     15751.719886  0.590367  1.493483                34536.085615   
2021/08/15     -8752.597204  0.148820  0.582362                25783.488410   
2021/08/16    -19415.434895 -0.958010 -1.771422                 6368.053516   
2021/08/17      4613.948331  0.059555 -0.313527                10982.001847   
2021/08/18      6870.373239  0.149024  0.107671                17852.375086   
2021/08/19     -2616.504104  0.089648 -0.079262                15235.870982   
2021/08/20      3316.261836  0.029082 -0.012249                18552.132817   
2021/08/21     15465.099080  0.534741  1.439276                34017.231897   
2021/08/22     -8338.881623  0.123938  0.542337                25678.350274   
2021/08/23    -19732.722387 -0.867167 -1.697932                 5945.627887   
2021/08/24      5293.242265 -0.005365 -0.337871                11238.870152   
2021/08/25      5897.342288  0.144592  0.139256                17136.212440   
2021/08/26     -2098.080567  0.064798 -0.095532                15038.131874   
2021/08/27      3423.032627  0.060817  0.020882                18461.164501   
2021/08/28     15996.419583  0.515684  1.370608                34457.584084   
2021/08/29     -8996.299123  0.147419  0.538153                25461.284961   
2021/08/30    -19438.048266 -0.827387 -1.619591                 6023.236695   
2021/08/31      5025.855059 -0.024818 -0.358857                11049.091753   

            p1_forecasted  p2_forecasted  
date                                      
2021/08/02       4.050834      -2.306268  
2021/08/03       4.190535      -2.537474  
2021/08/04       4.463011      -2.606557  
2021/08/05       4.568389      -2.653026  
2021/08/06       4.625191      -2.469813  
2021/08/07       5.149000      -1.034475  
2021/08/08       5.304960      -0.371734  
2021/08/09       4.248254      -2.297564  
2021/08/10       4.342102      -2.533007  
2021/08/11       4.509626      -2.515502  
2021/08/12       4.618106      -2.554117  
2021/08/13       4.675998      -2.523203  
2021/08/14       5.266365      -1.029720  
2021/08/15       5.415185      -0.447358  
2021/08/16       4.457175      -2.218780  
2021/08/17       4.516731      -2.532307  
2021/08/18       4.665754      -2.424636  
2021/08/19       4.755402      -2.503899  
2021/08/20       4.784485      -2.516147  
2021/08/21       5.319226      -1.076871  
2021/08/22       5.443164      -0.534534  
2021/08/23       4.575996      -2.232466  
2021/08/24       4.570632      -2.570337  
2021/08/25       4.715224      -2.431080  
2021/08/26       4.780021      -2.526612  
2021/08/27       4.840838      -2.505730  
2021/08/28       5.356523      -1.135123  
2021/08/29       5.503941      -0.596969  
2021/08/30       4.676555      -2.216561  
2021/08/31       4.651737      -2.575418  
MSE: 13358737.141434086
RMSE: 3654.9606210510788
Variance score: 0.890

다변량시계열분석을 한번에 하는 함수 선언

#변수로 전처리 및 PCA가 완료된 데이터프레임(df) 및 예측 및 평가를 원하는 일 수(day)를 입력
def get_result(df, day):
    print("차분 전 정상성 평가")
    for i in df.columns:
        adfuller_test = adfuller(df[i],autolag='AIC')
        print(i)
        print("ADF test statistic: {}".format(adfuller_test[0]))
        print("p-value: {}".format(adfuller_test[1]))

    df_diff = df.diff().dropna()
    print("차분 플롯")
    df_diff.plot(figsize=(20,20))

    print("차분")
    print(df_diff)

    print("차분 후 정상성 평가")
    for i in df.columns:
        adfuller_test = adfuller(df_diff[i],autolag='AIC')
        print(i)
        print("ADF test statistic: {}".format(adfuller_test[0]))
        print("p-value: {}".format(adfuller_test[1]))

    print("학습, 테스트 데이터 분리")
    train = df_diff.iloc[:-day,:]
    test = df_diff.iloc[-day:,:]
    print(train, test)


    print("VAR예측모델 생성")
    forecasting_model = VAR(train)
    results_aic = []
    for p in range(1,30):
      results = forecasting_model.fit(p)
      results_aic.append(results.aic)

    print("AIC 확인")
    sns.set()
    plt.plot(list(np.arange(1,30,1)), results_aic)
    plt.xlabel("Order")
    plt.ylabel("AIC")
    plt.show()

    print(results_aic)

    print("최적값 확인")
    results = forecasting_model.fit(np.argsort(results_aic)[0])
    print(results.summary())

    print(f"입력한{day}일 차분 예측")
    laaged_values = train.values
    forecast = pd.DataFrame(results.forecast(y= laaged_values, steps=day), index = test.index,\
                            columns=df.columns)

    print(f"입력한{day}일 차분을 더해서 원래값 예측")
    for i in df.columns:
        forecast[f'{i}_forecasted']= df[i].iloc[-day-1]+forecast[i].cumsum()
    print(forecast)

    test = df.iloc[-day:,:1]
    for i in test.columns:
        test[f'{i}_forecasted'] = forecast[f'{i}_forecasted']
    test.plot(figsize=(20,20))

    mse = mean_squared_error(test['ticketing_count'], test['ticketing_count_forecasted'])
    rmse = np.sqrt(mse)

    print(f'MSE: {mse}')
    print(f'RMSE: {rmse}')
    print('Variance score: {0:.3f}'.format(r2_score(test['ticketing_count'],
                                                    test['ticketing_count_forecasted'])))
    
    for i in range(3):
        test = df.iloc[-day:,i:i+1]
        for i in test.columns:
            test[f'{i}_forecasted'] = forecast[f'{i}_forecasted']
        test.plot(figsize=(20,20))

    test = df.iloc[-day:,:1]
    for i in test.columns:
        test[f'{i}_forecasted'] = forecast[f'{i}_forecasted']
    return np.round(test),df_diff
test,diff = get_result(df, 15)
차분 전 정상성 평가
ticketing_count
ADF test statistic: -2.099553733500803
p-value: 0.24469408536639126
p1
ADF test statistic: -0.21267008715649313
p-value: 0.9369944290578626
p2
ADF test statistic: -0.9660338259001354
p-value: 0.7654502757577035
차분 플롯
차분
            ticketing_count        p1        p2
date                                           
2019/01/02          -2332.0 -0.591827 -1.436540
2019/01/03           1429.0  0.050071  0.043894
2019/01/04            590.0  0.032127 -0.160157
2019/01/05          11667.0  0.453149  0.965645
2019/01/06          -5564.0  0.215044  0.535168
...                     ...       ...       ...
2021/08/27           3970.0  0.335959  0.163582
2021/08/28          25874.0 -0.250823  1.778201
2021/08/29         -13585.0  0.145392  0.699918
2021/08/30         -28219.0 -0.665134 -2.349837
2021/08/31           4930.0  0.730510 -0.323811

[973 rows x 3 columns]
차분 후 정상성 평가
ticketing_count
ADF test statistic: -8.90366524755091
p-value: 1.1532103667357817e-14
p1
ADF test statistic: -7.316333641273258
p-value: 1.2265309593054393e-10
p2
ADF test statistic: -8.654863167499396
p-value: 5.0006128672818535e-14
학습, 테스트 데이터 분리
            ticketing_count        p1        p2
date                                           
2019/01/02          -2332.0 -0.591827 -1.436540
2019/01/03           1429.0  0.050071  0.043894
2019/01/04            590.0  0.032127 -0.160157
2019/01/05          11667.0  0.453149  0.965645
2019/01/06          -5564.0  0.215044  0.535168
...                     ...       ...       ...
2021/08/12          -1827.0 -0.178059 -0.032996
2021/08/13           5810.0  0.349272  0.207221
2021/08/14          14591.0  0.313612  1.626783
2021/08/15          -7036.0 -0.030712  0.621387
2021/08/16         -18277.0 -0.492023 -0.229886

[958 rows x 3 columns]             ticketing_count        p1        p2
date                                           
2021/08/17           1743.0 -0.320392 -2.102970
2021/08/18          10810.0  0.231022 -0.418104
2021/08/19          -3599.0  0.186924  0.148053
2021/08/20           1624.0  0.140931  0.255090
2021/08/21          24481.0  0.576043  2.264528
2021/08/22          -9835.0 -0.445505  0.305457
2021/08/23         -28924.0 -0.563361 -2.491265
2021/08/24           9165.0  0.635171 -0.388304
2021/08/25           9759.0 -0.326547 -0.162770
2021/08/26          -7134.0  0.101249  0.099862
2021/08/27           3970.0  0.335959  0.163582
2021/08/28          25874.0 -0.250823  1.778201
2021/08/29         -13585.0  0.145392  0.699918
2021/08/30         -28219.0 -0.665134 -2.349837
2021/08/31           4930.0  0.730510 -0.323811
VAR예측모델 생성


C:\Users\USER\anaconda3\lib\site-packages\statsmodels\tsa\base\tsa_model.py:162: ValueWarning: No frequency information was provided, so inferred frequency D will be used.
  % freq, ValueWarning)


AIC 확인

[15.8737022538001, 15.554278410271971, 15.42503726462058, 15.313255688920648, 14.476857357042636, 13.799670206938172, 13.661354687346684, 13.652744965087638, 13.65034394549885, 13.663066176963177, 13.676870884127531, 13.66162318423407, 13.507055202897341, 13.47244459716127, 13.482325799633918, 13.494281207808443, 13.510649001542241, 13.522535370334111, 13.519399218185791, 13.476976838091648, 13.453097385373527, 13.470259209040648, 13.48221580482198, 13.494567255165336, 13.505613450190017, 13.521063949836032, 13.504017247110996, 13.503720886774584, 13.514578922713437]
최적값 확인
  Summary of Regression Results   
==================================
Model:                         VAR
Method:                        OLS
Date:           Tue, 07, Sep, 2021
Time:                     20:59:59
--------------------------------------------------------------------
No. of Equations:         3.00000    BIC:                    14.4220
Nobs:                     938.000    HQIC:                   13.8373
Log likelihood:          -10130.6    FPE:                    713208.
AIC:                      13.4770    Det(Omega_mle):         590375.
--------------------------------------------------------------------
Results for equation ticketing_count
======================================================================================
                         coefficient       std. error           t-stat            prob
--------------------------------------------------------------------------------------
const                     137.397069       216.604304            0.634           0.526
L1.ticketing_count         -0.513584         0.034014          -15.099           0.000
L1.p1                   -1759.508880       809.329167           -2.174           0.030
L1.p2                   -2814.672509       491.647557           -5.725           0.000
L2.ticketing_count         -0.593237         0.038117          -15.564           0.000
L2.p1                   -1337.527594       837.057275           -1.598           0.110
L2.p2                    -604.732473       523.399023           -1.155           0.248
L3.ticketing_count         -0.399109         0.042916           -9.300           0.000
L3.p1                   -1310.129759       853.557399           -1.535           0.125
L3.p2                   -1047.185430       556.290605           -1.882           0.060
L4.ticketing_count         -0.260825         0.044848           -5.816           0.000
L4.p1                    -425.549570       871.647245           -0.488           0.625
L4.p2                   -1215.857029       577.668676           -2.105           0.035
L5.ticketing_count         -0.338953         0.045827           -7.396           0.000
L5.p1                   -1259.837229       877.772932           -1.435           0.151
L5.p2                    -400.778550       599.968983           -0.668           0.504
L6.ticketing_count         -0.104848         0.047231           -2.220           0.026
L6.p1                    -709.122596       891.947324           -0.795           0.427
L6.p2                    -957.571826       616.884932           -1.552           0.121
L7.ticketing_count          0.163356         0.047392            3.447           0.001
L7.p1                    -453.748264       893.053827           -0.508           0.611
L7.p2                    -933.848854       628.666134           -1.485           0.137
L8.ticketing_count          0.019906         0.047132            0.422           0.673
L8.p1                    -410.380715       902.292000           -0.455           0.649
L8.p2                     338.790295       626.418795            0.541           0.589
L9.ticketing_count         -0.043334         0.046903           -0.924           0.356
L9.p1                    -489.041316       902.170843           -0.542           0.588
L9.p2                    -347.532906       623.858243           -0.557           0.577
L10.ticketing_count        -0.101521         0.046698           -2.174           0.030
L10.p1                   -303.387984       902.826540           -0.336           0.737
L10.p2                   -410.586762       625.347580           -0.657           0.511
L11.ticketing_count        -0.174002         0.046706           -3.725           0.000
L11.p1                   -459.367396       901.993573           -0.509           0.611
L11.p2                    -92.840724       626.130881           -0.148           0.882
L12.ticketing_count        -0.159532         0.047063           -3.390           0.001
L12.p1                    306.233096       901.230007            0.340           0.734
L12.p2                   -925.659501       624.161084           -1.483           0.138
L13.ticketing_count        -0.244851         0.047358           -5.170           0.000
L13.p1                    -81.061584       901.218637           -0.090           0.928
L13.p2                    -99.412064       627.224878           -0.158           0.874
L14.ticketing_count         0.059139         0.047729            1.239           0.215
L14.p1                   -529.121169       896.231262           -0.590           0.555
L14.p2                   -203.885819       628.994392           -0.324           0.746
L15.ticketing_count        -0.027799         0.047620           -0.584           0.559
L15.p1                  -1061.660926       895.302216           -1.186           0.236
L15.p2                    370.652086       615.832141            0.602           0.547
L16.ticketing_count        -0.021627         0.046164           -0.468           0.639
L16.p1                    485.528543       884.342606            0.549           0.583
L16.p2                   -828.731277       597.190638           -1.388           0.165
L17.ticketing_count        -0.068679         0.045335           -1.515           0.130
L17.p1                  -1817.344001       872.715650           -2.082           0.037
L17.p2                   -330.691981       581.849809           -0.568           0.570
L18.ticketing_count        -0.134263         0.043241           -3.105           0.002
L18.p1                   -330.376928       857.169463           -0.385           0.700
L18.p2                   -577.773017       559.515509           -1.033           0.302
L19.ticketing_count        -0.129775         0.038360           -3.383           0.001
L19.p1                   -987.140587       844.228315           -1.169           0.242
L19.p2                  -1069.787874       522.753937           -2.046           0.041
L20.ticketing_count        -0.155562         0.033262           -4.677           0.000
L20.p1                   -599.380228       815.244277           -0.735           0.462
L20.p2                   -512.530482       501.928095           -1.021           0.307
======================================================================================

Results for equation p1
======================================================================================
                         coefficient       std. error           t-stat            prob
--------------------------------------------------------------------------------------
const                       0.020551         0.009499            2.163           0.031
L1.ticketing_count          0.000000         0.000001            0.048           0.961
L1.p1                      -0.299464         0.035493           -8.437           0.000
L1.p2                      -0.121589         0.021561           -5.639           0.000
L2.ticketing_count         -0.000005         0.000002           -2.787           0.005
L2.p1                      -0.215902         0.036709           -5.881           0.000
L2.p2                      -0.029040         0.022954           -1.265           0.206
L3.ticketing_count         -0.000003         0.000002           -1.810           0.070
L3.p1                      -0.229319         0.037433           -6.126           0.000
L3.p2                      -0.051983         0.024396           -2.131           0.033
L4.ticketing_count         -0.000005         0.000002           -2.637           0.008
L4.p1                      -0.136179         0.038226           -3.562           0.000
L4.p2                      -0.070959         0.025333           -2.801           0.005
L5.ticketing_count         -0.000003         0.000002           -1.319           0.187
L5.p1                      -0.210324         0.038494           -5.464           0.000
L5.p2                      -0.020912         0.026311           -0.795           0.427
L6.ticketing_count         -0.000005         0.000002           -2.224           0.026
L6.p1                      -0.104482         0.039116           -2.671           0.008
L6.p2                      -0.052080         0.027053           -1.925           0.054
L7.ticketing_count         -0.000003         0.000002           -1.233           0.218
L7.p1                       0.157207         0.039165            4.014           0.000
L7.p2                       0.004342         0.027570            0.157           0.875
L8.ticketing_count         -0.000003         0.000002           -1.264           0.206
L8.p1                      -0.000355         0.039570           -0.009           0.993
L8.p2                      -0.000437         0.027471           -0.016           0.987
L9.ticketing_count         -0.000004         0.000002           -1.713           0.087
L9.p1                      -0.055119         0.039564           -1.393           0.164
L9.p2                      -0.019543         0.027359           -0.714           0.475
L10.ticketing_count        -0.000000         0.000002           -0.135           0.893
L10.p1                      0.022696         0.039593            0.573           0.566
L10.p2                     -0.046427         0.027424           -1.693           0.090
L11.ticketing_count        -0.000002         0.000002           -0.743           0.458
L11.p1                      0.026180         0.039557            0.662           0.508
L11.p2                     -0.024453         0.027459           -0.891           0.373
L12.ticketing_count        -0.000001         0.000002           -0.582           0.561
L12.p1                      0.039089         0.039523            0.989           0.323
L12.p2                     -0.042649         0.027372           -1.558           0.119
L13.ticketing_count        -0.000000         0.000002           -0.215           0.830
L13.p1                      0.018826         0.039523            0.476           0.634
L13.p2                     -0.049937         0.027507           -1.815           0.069
L14.ticketing_count        -0.000001         0.000002           -0.326           0.745
L14.p1                      0.110330         0.039304            2.807           0.005
L14.p2                      0.018926         0.027584            0.686           0.493
L15.ticketing_count         0.000002         0.000002            0.882           0.378
L15.p1                     -0.042184         0.039263           -1.074           0.283
L15.p2                     -0.008542         0.027007           -0.316           0.752
L16.ticketing_count         0.000002         0.000002            0.927           0.354
L16.p1                     -0.026036         0.038783           -0.671           0.502
L16.p2                     -0.048500         0.026190           -1.852           0.064
L17.ticketing_count         0.000000         0.000002            0.241           0.809
L17.p1                     -0.086044         0.038273           -2.248           0.025
L17.p2                     -0.007966         0.025517           -0.312           0.755
L18.ticketing_count        -0.000000         0.000002           -0.040           0.968
L18.p1                     -0.111739         0.037591           -2.972           0.003
L18.p2                     -0.033762         0.024537           -1.376           0.169
L19.ticketing_count        -0.000001         0.000002           -0.555           0.579
L19.p1                     -0.124944         0.037023           -3.375           0.001
L19.p2                     -0.012871         0.022925           -0.561           0.574
L20.ticketing_count        -0.000002         0.000001           -1.150           0.250
L20.p1                     -0.128311         0.035752           -3.589           0.000
L20.p2                     -0.020504         0.022012           -0.931           0.352
======================================================================================

Results for equation p2
======================================================================================
                         coefficient       std. error           t-stat            prob
--------------------------------------------------------------------------------------
const                       0.000214         0.015836            0.014           0.989
L1.ticketing_count          0.000002         0.000002            0.842           0.400
L1.p1                      -0.173026         0.059170           -2.924           0.003
L1.p2                      -0.390533         0.035944          -10.865           0.000
L2.ticketing_count         -0.000003         0.000003           -1.212           0.225
L2.p1                       0.049973         0.061197            0.817           0.414
L2.p2                      -0.420902         0.038266          -11.000           0.000
L3.ticketing_count         -0.000002         0.000003           -0.764           0.445
L3.p1                      -0.047697         0.062403           -0.764           0.445
L3.p2                      -0.359793         0.040670           -8.847           0.000
L4.ticketing_count         -0.000001         0.000003           -0.241           0.810
L4.p1                       0.000511         0.063726            0.008           0.994
L4.p2                      -0.375090         0.042233           -8.881           0.000
L5.ticketing_count         -0.000001         0.000003           -0.248           0.804
L5.p1                      -0.126026         0.064174           -1.964           0.050
L5.p2                      -0.303920         0.043864           -6.929           0.000
L6.ticketing_count         -0.000001         0.000003           -0.367           0.714
L6.p1                      -0.045684         0.065210           -0.701           0.484
L6.p2                      -0.269930         0.045100           -5.985           0.000
L7.ticketing_count          0.000000         0.000003            0.091           0.927
L7.p1                       0.132487         0.065291            2.029           0.042
L7.p2                      -0.001049         0.045962           -0.023           0.982
L8.ticketing_count         -0.000000         0.000003           -0.056           0.955
L8.p1                      -0.027626         0.065966           -0.419           0.675
L8.p2                      -0.077419         0.045797           -1.690           0.091
L9.ticketing_count          0.000002         0.000003            0.515           0.606
L9.p1                      -0.006636         0.065957           -0.101           0.920
L9.p2                      -0.148114         0.045610           -3.247           0.001
L10.ticketing_count         0.000002         0.000003            0.530           0.596
L10.p1                     -0.014039         0.066005           -0.213           0.832
L10.p2                     -0.090437         0.045719           -1.978           0.048
L11.ticketing_count        -0.000002         0.000003           -0.459           0.646
L11.p1                      0.118658         0.065944            1.799           0.072
L11.p2                     -0.116157         0.045776           -2.537           0.011
L12.ticketing_count        -0.000001         0.000003           -0.351           0.725
L12.p1                      0.066486         0.065889            1.009           0.313
L12.p2                     -0.166486         0.045632           -3.648           0.000
L13.ticketing_count        -0.000001         0.000003           -0.385           0.700
L13.p1                     -0.114872         0.065888           -1.743           0.081
L13.p2                     -0.101086         0.045856           -2.204           0.027
L14.ticketing_count        -0.000000         0.000003           -0.072           0.943
L14.p1                      0.119909         0.065523            1.830           0.067
L14.p2                      0.052128         0.045986            1.134           0.257
L15.ticketing_count        -0.000001         0.000003           -0.251           0.802
L15.p1                     -0.060677         0.065455           -0.927           0.354
L15.p2                     -0.020025         0.045023           -0.445           0.656
L16.ticketing_count        -0.000000         0.000003           -0.056           0.956
L16.p1                      0.011610         0.064654            0.180           0.857
L16.p2                     -0.151830         0.043660           -3.478           0.001
L17.ticketing_count        -0.000000         0.000003           -0.054           0.957
L17.p1                     -0.132340         0.063804           -2.074           0.038
L17.p2                     -0.098449         0.042539           -2.314           0.021
L18.ticketing_count        -0.000001         0.000003           -0.303           0.762
L18.p1                     -0.071177         0.062667           -1.136           0.256
L18.p2                     -0.144206         0.040906           -3.525           0.000
L19.ticketing_count        -0.000002         0.000003           -0.588           0.557
L19.p1                     -0.078760         0.061721           -1.276           0.202
L19.p2                     -0.156755         0.038218           -4.102           0.000
L20.ticketing_count         0.000000         0.000002            0.172           0.863
L20.p1                     -0.149846         0.059602           -2.514           0.012
L20.p2                     -0.098237         0.036696           -2.677           0.007
======================================================================================

Correlation matrix of residuals
                   ticketing_count        p1        p2
ticketing_count           1.000000  0.141866  0.180670
p1                        0.141866  1.000000  0.314378
p2                        0.180670  0.314378  1.000000



입력한15일 차분 예측
입력한15일 차분을 더해서 원래값 예측
            ticketing_count        p1        p2  ticketing_count_forecasted  \
date                                                                          
2021/08/17     -1379.130392  0.039463 -0.867158                 6142.869608   
2021/08/18      7970.437498  0.030421 -0.518052                14113.307107   
2021/08/19       699.704730  0.038485 -0.165383                14813.011837   
2021/08/20      2127.266537  0.128304 -0.060137                16940.278374   
2021/08/21     15327.708405  0.459371  1.413296                32267.986779   
2021/08/22     -6374.755724  0.066170  0.696624                25893.231054   
2021/08/23    -21297.623296 -0.800766 -1.538394                 4595.607758   
2021/08/24      3656.475441  0.085582 -0.242410                 8252.083199   
2021/08/25      5477.033115 -0.096167 -0.289664                13729.116314   
2021/08/26      1772.842975  0.071644 -0.065844                15501.959289   
2021/08/27      1385.840585  0.168161  0.130676                16887.799874   
2021/08/28     15963.285158  0.442417  1.293903                32851.085032   
2021/08/29     -5968.719666  0.173523  0.678578                26882.365366   
2021/08/30    -20794.496932 -0.691774 -1.368857                 6087.868434   
2021/08/31      1866.122584  0.036551 -0.382473                 7953.991018   

            p1_forecasted  p2_forecasted  
date                                      
2021/08/17       4.605046      -1.734482  
2021/08/18       4.635467      -2.252534  
2021/08/19       4.673951      -2.417916  
2021/08/20       4.802255      -2.478054  
2021/08/21       5.261626      -1.064758  
2021/08/22       5.327796      -0.368134  
2021/08/23       4.527030      -1.906528  
2021/08/24       4.612612      -2.148938  
2021/08/25       4.516446      -2.438602  
2021/08/26       4.588090      -2.504447  
2021/08/27       4.756251      -2.373771  
2021/08/28       5.198668      -1.079868  
2021/08/29       5.372191      -0.401290  
2021/08/30       4.680418      -1.770146  
2021/08/31       4.716968      -2.152620  
MSE: 33627318.40506824
RMSE: 5798.906656005789
Variance score: 0.783

#차분 저장
diff.to_csv("F:\\drive\\WebWorkPlace2021\\jupyter\\code\\차분.csv")
#실제값과 예측값 저장
test
test.to_csv("F:\\drive\\WebWorkPlace2021\\jupyter\\code\\예매건수예측(15일).csv")
#31일치 예측 수행
test,diff = get_result(df, 31)
차분 전 정상성 평가
ticketing_count
ADF test statistic: -2.099553733500803
p-value: 0.24469408536639126
p1
ADF test statistic: -0.21267008715610644
p-value: 0.9369944290579096
p2
ADF test statistic: -0.9660338256671395
p-value: 0.7654502758399014
차분 플롯
차분
            ticketing_count        p1        p2
date                                           
2019/01/02          -2332.0 -0.591827 -1.436540
2019/01/03           1429.0  0.050071  0.043894
2019/01/04            590.0  0.032127 -0.160157
2019/01/05          11667.0  0.453149  0.965645
2019/01/06          -5564.0  0.215044  0.535168
...                     ...       ...       ...
2021/08/27           3970.0  0.335959  0.163582
2021/08/28          25874.0 -0.250823  1.778201
2021/08/29         -13585.0  0.145392  0.699918
2021/08/30         -28219.0 -0.665134 -2.349837
2021/08/31           4930.0  0.730510 -0.323811

[973 rows x 3 columns]
차분 후 정상성 평가
ticketing_count
ADF test statistic: -8.90366524755091
p-value: 1.1532103667357817e-14
p1
ADF test statistic: -7.31633364127461
p-value: 1.2265309592959857e-10
p2
ADF test statistic: -8.654863166473886
p-value: 5.00061289751736e-14
학습, 테스트 데이터 분리
            ticketing_count        p1        p2
date                                           
2019/01/02          -2332.0 -0.591827 -1.436540
2019/01/03           1429.0  0.050071  0.043894
2019/01/04            590.0  0.032127 -0.160157
2019/01/05          11667.0  0.453149  0.965645
2019/01/06          -5564.0  0.215044  0.535168
...                     ...       ...       ...
2021/07/27           7910.0  0.374974  0.102941
2021/07/28           7195.0  0.271976 -0.397341
2021/07/29          -1568.0  0.121974  0.071939
2021/07/30           1240.0 -0.323097 -0.009642
2021/07/31          11692.0  0.806326  1.693124

[942 rows x 3 columns]             ticketing_count        p1        p2
date                                           
2021/08/01          -1419.0 -0.083921  0.568040
2021/08/02         -23309.0 -1.197897 -1.823121
2021/08/03           6021.0  0.382762 -0.307690
2021/08/04           5184.0  0.224371 -0.159779
2021/08/05          -1820.0  0.213700  0.045172
2021/08/06           2199.0  0.210503  0.053557
2021/08/07          15793.0  0.433313  1.324466
2021/08/08          -6053.0  0.227528  0.915187
2021/08/09         -22049.0 -1.476812 -2.419552
2021/08/10           4498.0  0.864029 -0.313854
2021/08/11           5951.0 -0.361891  0.011769
2021/08/12          -1827.0 -0.178059 -0.032996
2021/08/13           5810.0  0.349272  0.207221
2021/08/14          14591.0  0.313612  1.626783
2021/08/15          -7036.0 -0.030712  0.621387
2021/08/16         -18277.0 -0.492023 -0.229886
2021/08/17           1743.0 -0.320392 -2.102970
2021/08/18          10810.0  0.231022 -0.418104
2021/08/19          -3599.0  0.186924  0.148053
2021/08/20           1624.0  0.140931  0.255090
2021/08/21          24481.0  0.576043  2.264528
2021/08/22          -9835.0 -0.445505  0.305457
2021/08/23         -28924.0 -0.563361 -2.491265
2021/08/24           9165.0  0.635171 -0.388304
2021/08/25           9759.0 -0.326547 -0.162770
2021/08/26          -7134.0  0.101249  0.099862
2021/08/27           3970.0  0.335959  0.163582
2021/08/28          25874.0 -0.250823  1.778201
2021/08/29         -13585.0  0.145392  0.699918
2021/08/30         -28219.0 -0.665134 -2.349837
2021/08/31           4930.0  0.730510 -0.323811
VAR예측모델 생성


C:\Users\USER\anaconda3\lib\site-packages\statsmodels\tsa\base\tsa_model.py:162: ValueWarning: No frequency information was provided, so inferred frequency D will be used.
  % freq, ValueWarning)


AIC 확인

[15.87563729489809, 15.557357216287832, 15.427078479994226, 15.320142887020664, 14.48060172738807, 13.815459196908648, 13.674602843731316, 13.666747066401175, 13.664793526873849, 13.677695046468395, 13.6932228219071, 13.678713838592259, 13.52530614904882, 13.491261062425483, 13.50126835271658, 13.513745267270556, 13.530328749823905, 13.543306011793984, 13.540264193133444, 13.496731046618704, 13.470470090515716, 13.488196994232275, 13.500023311385208, 13.511766957195414, 13.522155988711997, 13.538536035549402, 13.521722836728927, 13.519968653073875, 13.53152912258182]
최적값 확인
  Summary of Regression Results   
==================================
Model:                         VAR
Method:                        OLS
Date:           Tue, 07, Sep, 2021
Time:                     19:08:44
--------------------------------------------------------------------
No. of Equations:         3.00000    BIC:                    14.4547
Nobs:                     922.000    HQIC:                   13.8623
Log likelihood:          -9963.78    FPE:                    727458.
AIC:                      13.4967    Det(Omega_mle):         600261.
--------------------------------------------------------------------
Results for equation ticketing_count
======================================================================================
                         coefficient       std. error           t-stat            prob
--------------------------------------------------------------------------------------
const                     135.454294       221.234594            0.612           0.540
L1.ticketing_count         -0.510798         0.034407          -14.846           0.000
L1.p1                   -1784.447639       823.130935           -2.168           0.030
L1.p2                   -2826.770380       496.704652           -5.691           0.000
L2.ticketing_count         -0.592900         0.038506          -15.398           0.000
L2.p1                   -1269.958322       850.326719           -1.493           0.135
L2.p2                    -604.709203       528.855671           -1.143           0.253
L3.ticketing_count         -0.397590         0.043349           -9.172           0.000
L3.p1                   -1317.606646       866.633658           -1.520           0.128
L3.p2                   -1048.949905       561.963174           -1.867           0.062
L4.ticketing_count         -0.260854         0.045270           -5.762           0.000
L4.p1                    -382.628531       886.053692           -0.432           0.666
L4.p2                   -1212.392013       583.699341           -2.077           0.038
L5.ticketing_count         -0.338530         0.046262           -7.318           0.000
L5.p1                   -1263.337670       891.157588           -1.418           0.156
L5.p2                    -404.074380       606.186613           -0.667           0.505
L6.ticketing_count         -0.104286         0.047675           -2.187           0.029
L6.p1                    -644.443541       907.048346           -0.710           0.477
L6.p2                    -965.143037       623.511658           -1.548           0.122
L7.ticketing_count          0.162247         0.047824            3.393           0.001
L7.p1                    -425.206322       907.596583           -0.468           0.639
L7.p2                    -926.225112       635.023958           -1.459           0.145
L8.ticketing_count          0.019225         0.047559            0.404           0.686
L8.p1                    -396.937584       916.552241           -0.433           0.665
L8.p2                     340.830832       632.590717            0.539           0.590
L9.ticketing_count         -0.043038         0.047329           -0.909           0.363
L9.p1                    -516.977764       916.524021           -0.564           0.573
L9.p2                    -342.087069       630.096703           -0.543           0.587
L10.ticketing_count        -0.101747         0.047127           -2.159           0.031
L10.p1                   -272.635360       917.673841           -0.297           0.766
L10.p2                   -399.453102       631.553283           -0.632           0.527
L11.ticketing_count        -0.173021         0.047134           -3.671           0.000
L11.p1                   -544.237686       916.661743           -0.594           0.553
L11.p2                    -61.556054       632.571114           -0.097           0.922
L12.ticketing_count        -0.159145         0.047497           -3.351           0.001
L12.p1                    322.326402       915.851616            0.352           0.725
L12.p2                   -923.789816       630.296374           -1.466           0.143
L13.ticketing_count        -0.243933         0.047797           -5.103           0.000
L13.p1                   -100.210598       915.813894           -0.109           0.913
L13.p2                    -89.788479       633.348356           -0.142           0.887
L14.ticketing_count         0.059717         0.048175            1.240           0.215
L14.p1                   -509.308398       911.364183           -0.559           0.576
L14.p2                   -200.390619       634.891882           -0.316           0.752
L15.ticketing_count        -0.027825         0.048068           -0.579           0.563
L15.p1                  -1035.054483       913.510861           -1.133           0.257
L15.p2                    363.969355       622.217002            0.585           0.559
L16.ticketing_count        -0.021924         0.046580           -0.471           0.638
L16.p1                    490.271300       903.091537            0.543           0.587
L16.p2                   -817.396038       603.840782           -1.354           0.176
L17.ticketing_count        -0.068145         0.045745           -1.490           0.136
L17.p1                  -1857.094971       890.681751           -2.085           0.037
L17.p2                   -326.716956       588.480118           -0.555           0.579
L18.ticketing_count        -0.133925         0.043638           -3.069           0.002
L18.p1                   -346.685447       874.038991           -0.397           0.692
L18.p2                   -548.384527       566.530853           -0.968           0.333
L19.ticketing_count        -0.128832         0.038718           -3.327           0.001
L19.p1                  -1008.881602       860.967806           -1.172           0.241
L19.p2                  -1055.210407       528.914092           -1.995           0.046
L20.ticketing_count        -0.156058         0.033573           -4.648           0.000
L20.p1                   -541.720630       831.361945           -0.652           0.515
L20.p2                   -491.918515       508.820835           -0.967           0.334
======================================================================================

Results for equation p1
======================================================================================
                         coefficient       std. error           t-stat            prob
--------------------------------------------------------------------------------------
const                       0.021101         0.009624            2.193           0.028
L1.ticketing_count         -0.000000         0.000001           -0.049           0.961
L1.p1                      -0.293984         0.035806           -8.210           0.000
L1.p2                      -0.120798         0.021607           -5.591           0.000
L2.ticketing_count         -0.000005         0.000002           -2.911           0.004
L2.p1                      -0.211571         0.036989           -5.720           0.000
L2.p2                      -0.031798         0.023005           -1.382           0.167
L3.ticketing_count         -0.000003         0.000002           -1.811           0.070
L3.p1                      -0.235865         0.037698           -6.257           0.000
L3.p2                      -0.052685         0.024445           -2.155           0.031
L4.ticketing_count         -0.000005         0.000002           -2.670           0.008
L4.p1                      -0.130900         0.038543           -3.396           0.001
L4.p2                      -0.072598         0.025391           -2.859           0.004
L5.ticketing_count         -0.000003         0.000002           -1.362           0.173
L5.p1                      -0.204512         0.038765           -5.276           0.000
L5.p2                      -0.023166         0.026369           -0.879           0.380
L6.ticketing_count         -0.000004         0.000002           -2.164           0.030
L6.p1                      -0.107265         0.039456           -2.719           0.007
L6.p2                      -0.051605         0.027123           -1.903           0.057
L7.ticketing_count         -0.000003         0.000002           -1.250           0.211
L7.p1                       0.157641         0.039480            3.993           0.000
L7.p2                       0.004611         0.027623            0.167           0.867
L8.ticketing_count         -0.000002         0.000002           -1.187           0.235
L8.p1                       0.002651         0.039870            0.066           0.947
L8.p2                      -0.002890         0.027518           -0.105           0.916
L9.ticketing_count         -0.000004         0.000002           -1.763           0.078
L9.p1                      -0.050102         0.039869           -1.257           0.209
L9.p2                      -0.018999         0.027409           -0.693           0.488
L10.ticketing_count        -0.000000         0.000002           -0.091           0.927
L10.p1                      0.018886         0.039919            0.473           0.636
L10.p2                     -0.046798         0.027472           -1.703           0.088
L11.ticketing_count        -0.000002         0.000002           -0.734           0.463
L11.p1                      0.030265         0.039875            0.759           0.448
L11.p2                     -0.026061         0.027517           -0.947           0.344
L12.ticketing_count        -0.000001         0.000002           -0.642           0.521
L12.p1                      0.038584         0.039839            0.968           0.333
L12.p2                     -0.042031         0.027418           -1.533           0.125
L13.ticketing_count        -0.000000         0.000002           -0.230           0.818
L13.p1                      0.011543         0.039838            0.290           0.772
L13.p2                     -0.047724         0.027551           -1.732           0.083
L14.ticketing_count        -0.000001         0.000002           -0.338           0.736
L14.p1                      0.108620         0.039644            2.740           0.006
L14.p2                      0.017694         0.027618            0.641           0.522
L15.ticketing_count         0.000002         0.000002            0.808           0.419
L15.p1                     -0.040511         0.039738           -1.019           0.308
L15.p2                     -0.007494         0.027066           -0.277           0.782
L16.ticketing_count         0.000002         0.000002            0.954           0.340
L16.p1                     -0.038941         0.039284           -0.991           0.322
L16.p2                     -0.046095         0.026267           -1.755           0.079
L17.ticketing_count         0.000000         0.000002            0.227           0.820
L17.p1                     -0.082103         0.038745           -2.119           0.034
L17.p2                     -0.009225         0.025599           -0.360           0.719
L18.ticketing_count        -0.000000         0.000002           -0.102           0.918
L18.p1                     -0.110973         0.038021           -2.919           0.004
L18.p2                     -0.032278         0.024644           -1.310           0.190
L19.ticketing_count        -0.000001         0.000002           -0.543           0.587
L19.p1                     -0.130390         0.037452           -3.482           0.000
L19.p2                     -0.013155         0.023008           -0.572           0.567
L20.ticketing_count        -0.000002         0.000001           -1.193           0.233
L20.p1                     -0.133846         0.036164           -3.701           0.000
L20.p2                     -0.019621         0.022134           -0.886           0.375
======================================================================================

Results for equation p2
======================================================================================
                         coefficient       std. error           t-stat            prob
--------------------------------------------------------------------------------------
const                       0.000085         0.016045            0.005           0.996
L1.ticketing_count          0.000002         0.000002            0.786           0.432
L1.p1                      -0.170249         0.059697           -2.852           0.004
L1.p2                      -0.391082         0.036023          -10.856           0.000
L2.ticketing_count         -0.000004         0.000003           -1.254           0.210
L2.p1                       0.061483         0.061669            0.997           0.319
L2.p2                      -0.424604         0.038355          -11.070           0.000
L3.ticketing_count         -0.000003         0.000003           -0.804           0.421
L3.p1                      -0.049322         0.062852           -0.785           0.433
L3.p2                      -0.361083         0.040756           -8.860           0.000
L4.ticketing_count         -0.000001         0.000003           -0.258           0.796
L4.p1                       0.013022         0.064260            0.203           0.839
L4.p2                      -0.375584         0.042332           -8.872           0.000
L5.ticketing_count         -0.000001         0.000003           -0.283           0.777
L5.p1                      -0.111835         0.064630           -1.730           0.084
L5.p2                      -0.304613         0.043963           -6.929           0.000
L6.ticketing_count         -0.000001         0.000003           -0.302           0.763
L6.p1                      -0.055170         0.065783           -0.839           0.402
L6.p2                      -0.264689         0.045220           -5.853           0.000
L7.ticketing_count          0.000000         0.000003            0.062           0.951
L7.p1                       0.146130         0.065823            2.220           0.026
L7.p2                       0.001996         0.046055            0.043           0.965
L8.ticketing_count         -0.000000         0.000003           -0.019           0.985
L8.p1                      -0.032761         0.066472           -0.493           0.622
L8.p2                      -0.075155         0.045878           -1.638           0.101
L9.ticketing_count          0.000002         0.000003            0.530           0.596
L9.p1                      -0.006571         0.066470           -0.099           0.921
L9.p2                      -0.144774         0.045697           -3.168           0.002
L10.ticketing_count         0.000002         0.000003            0.496           0.620
L10.p1                     -0.020559         0.066553           -0.309           0.757
L10.p2                     -0.085479         0.045803           -1.866           0.062
L11.ticketing_count        -0.000001         0.000003           -0.394           0.693
L11.p1                      0.103954         0.066480            1.564           0.118
L11.p2                     -0.112792         0.045877           -2.459           0.014
L12.ticketing_count        -0.000001         0.000003           -0.362           0.718
L12.p1                      0.057462         0.066421            0.865           0.387
L12.p2                     -0.162549         0.045712           -3.556           0.000
L13.ticketing_count        -0.000001         0.000003           -0.378           0.706
L13.p1                     -0.121417         0.066419           -1.828           0.068
L13.p2                     -0.096714         0.045933           -2.106           0.035
L14.ticketing_count        -0.000000         0.000003           -0.063           0.950
L14.p1                      0.115739         0.066096            1.751           0.080
L14.p2                      0.053432         0.046045            1.160           0.246
L15.ticketing_count        -0.000001         0.000003           -0.351           0.725
L15.p1                     -0.063144         0.066252           -0.953           0.341
L15.p2                     -0.017982         0.045126           -0.398           0.690
L16.ticketing_count         0.000000         0.000003            0.009           0.993
L16.p1                      0.001221         0.065496            0.019           0.985
L16.p2                     -0.152165         0.043793           -3.475           0.001
L17.ticketing_count        -0.000000         0.000003           -0.066           0.947
L17.p1                     -0.131623         0.064596           -2.038           0.042
L17.p2                     -0.096203         0.042679           -2.254           0.024
L18.ticketing_count        -0.000001         0.000003           -0.302           0.763
L18.p1                     -0.076353         0.063389           -1.205           0.228
L18.p2                     -0.142043         0.041087           -3.457           0.001
L19.ticketing_count        -0.000002         0.000003           -0.623           0.533
L19.p1                     -0.084186         0.062441           -1.348           0.178
L19.p2                     -0.154012         0.038359           -4.015           0.000
L20.ticketing_count         0.000000         0.000002            0.097           0.923
L20.p1                     -0.153419         0.060294           -2.545           0.011
L20.p2                     -0.098803         0.036902           -2.677           0.007
======================================================================================

Correlation matrix of residuals
                   ticketing_count        p1        p2
ticketing_count           1.000000  0.145215  0.180840
p1                        0.145215  1.000000  0.313024
p2                        0.180840  0.313024  1.000000



입력한31일 차분 예측
입력한31일 차분을 더해서 원래값 예측
            ticketing_count        p1        p2  ticketing_count_forecasted  \
date                                                                          
2021/08/01     -7672.161584  0.240809  0.652724                21592.838416   
2021/08/02    -19234.859185 -1.139989 -2.021386                 2357.979231   
2021/08/03      6614.862081  0.141454 -0.163036                 8972.841312   
2021/08/04      6160.817413  0.217028 -0.094239                15133.658726   
2021/08/05     -2617.425303  0.116703 -0.052759                12516.233422   
2021/08/06      4547.255332  0.012815  0.139671                17063.488755   
2021/08/07     14845.387190  0.548608  1.459166                31908.875945   
2021/08/08     -9267.871208  0.236678  0.727491                22641.004737   
2021/08/09    -20279.112519 -1.089021 -1.994745                 2361.892218   
2021/08/10      7840.176624  0.106145 -0.210485                10202.068842   
2021/08/11      4442.480825  0.144063  0.001570                14644.549667   
2021/08/12      -835.785365  0.118991  0.008042                13808.764302   
2021/08/13      3614.169622  0.043069 -0.000119                17422.933924   
2021/08/14     15654.777920  0.593197  1.458439                33077.711844   
2021/08/15    -11381.048597  0.213163  0.667913                21696.663247   
2021/08/16    -18757.621828 -1.036709 -1.862996                 2939.041418   
2021/08/17      6856.851281  0.073523 -0.273500                 9795.892700   
2021/08/18      6065.562289  0.117522  0.062516                15861.454989   
2021/08/19     -2108.765441  0.091566 -0.046614                13752.689547   
2021/08/20      3696.115208  0.000053 -0.044116                17448.804755   
2021/08/21     15445.662302  0.538021  1.412922                32894.467058   
2021/08/22    -10999.674744  0.189025  0.634848                21894.792313   
2021/08/23    -19159.381682 -0.918728 -1.756677                 2735.410632   
2021/08/24      7203.628853  0.030576 -0.301209                 9939.039484   
2021/08/25      5461.315648  0.121360  0.111626                15400.355132   
2021/08/26     -2017.323642  0.070288 -0.063346                13383.031489   
2021/08/27      3781.523170  0.036569 -0.025455                17164.554659   
2021/08/28     15917.544589  0.514517  1.352018                33082.099248   
2021/08/29    -11288.407714  0.188214  0.610122                21793.691534   
2021/08/30    -19093.107271 -0.874509 -1.676044                 2700.584262   
2021/08/31      6938.956752  0.009714 -0.326189                 9639.541015   

            p1_forecasted  p2_forecasted  
date                                      
2021/08/01       5.408619      -0.301303  
2021/08/02       4.268630      -2.322689  
2021/08/03       4.410084      -2.485725  
2021/08/04       4.627113      -2.579965  
2021/08/05       4.743815      -2.632723  
2021/08/06       4.756630      -2.493053  
2021/08/07       5.305238      -1.033886  
2021/08/08       5.541916      -0.306395  
2021/08/09       4.452895      -2.301140  
2021/08/10       4.559040      -2.511625  
2021/08/11       4.703103      -2.510055  
2021/08/12       4.822095      -2.502012  
2021/08/13       4.865163      -2.502131  
2021/08/14       5.458360      -1.043692  
2021/08/15       5.671523      -0.375779  
2021/08/16       4.634814      -2.238775  
2021/08/17       4.708337      -2.512275  
2021/08/18       4.825858      -2.449760  
2021/08/19       4.917424      -2.496374  
2021/08/20       4.917477      -2.540490  
2021/08/21       5.455498      -1.127567  
2021/08/22       5.644523      -0.492719  
2021/08/23       4.725795      -2.249396  
2021/08/24       4.756371      -2.550605  
2021/08/25       4.877731      -2.438979  
2021/08/26       4.948019      -2.502325  
2021/08/27       4.984588      -2.527780  
2021/08/28       5.499105      -1.175762  
2021/08/29       5.687319      -0.565640  
2021/08/30       4.812810      -2.241684  
2021/08/31       4.822524      -2.567873  
MSE: 21794710.70737103
RMSE: 4668.480556602012
Variance score: 0.819

#31일치 예측 수행 저장
test
test.to_csv("F:\\drive\\WebWorkPlace2021\\jupyter\\code\\예매건수예측(30일).csv")
#62일치 예측 수행 저장
test,diff = get_result(df, 62)
test.to_csv("F:\\drive\\WebWorkPlace2021\\jupyter\\code\\예매건수예측(60일).csv")
차분 전 정상성 평가
ticketing_count
ADF test statistic: -2.099553733500803
p-value: 0.24469408536639126
p1
ADF test statistic: -0.21267008715610644
p-value: 0.9369944290579096
p2
ADF test statistic: -0.9660338256671395
p-value: 0.7654502758399014
차분 플롯
차분
            ticketing_count        p1        p2
date                                           
2019/01/02          -2332.0 -0.591827 -1.436540
2019/01/03           1429.0  0.050071  0.043894
2019/01/04            590.0  0.032127 -0.160157
2019/01/05          11667.0  0.453149  0.965645
2019/01/06          -5564.0  0.215044  0.535168
...                     ...       ...       ...
2021/08/27           3970.0  0.335959  0.163582
2021/08/28          25874.0 -0.250823  1.778201
2021/08/29         -13585.0  0.145392  0.699918
2021/08/30         -28219.0 -0.665134 -2.349837
2021/08/31           4930.0  0.730510 -0.323811

[973 rows x 3 columns]
차분 후 정상성 평가
ticketing_count
ADF test statistic: -8.90366524755091
p-value: 1.1532103667357817e-14
p1
ADF test statistic: -7.31633364127461
p-value: 1.2265309592959857e-10
p2
ADF test statistic: -8.654863166473886
p-value: 5.00061289751736e-14
학습, 테스트 데이터 분리
            ticketing_count        p1        p2
date                                           
2019/01/02          -2332.0 -0.591827 -1.436540
2019/01/03           1429.0  0.050071  0.043894
2019/01/04            590.0  0.032127 -0.160157
2019/01/05          11667.0  0.453149  0.965645
2019/01/06          -5564.0  0.215044  0.535168
...                     ...       ...       ...
2021/06/26          30644.0  0.388360  1.257844
2021/06/27         -14777.0  0.219874  0.414628
2021/06/28         -33224.0 -0.868161 -1.371930
2021/06/29           6803.0  0.379811 -0.154252
2021/06/30           9164.0  0.049356  0.075260

[911 rows x 3 columns]             ticketing_count        p1        p2
date                                           
2021/07/01          -7908.0 -0.539226 -1.429798
2021/07/02           6262.0  0.176894 -0.161103
2021/07/03          25836.0  0.896067  1.906416
2021/07/04         -11935.0  0.063430  0.781533
2021/07/05         -28317.0 -1.381765 -2.619479
2021/07/06           4418.0  0.438984 -0.023562
2021/07/07           6981.0  0.296948 -0.196619
2021/07/08            -74.0  0.549223  0.449346
2021/07/09           3952.0  0.168500 -0.055949
2021/07/10          12881.0  0.569024  1.851338
2021/07/11          -8866.0  0.812047  0.715844
2021/07/12         -20980.0 -1.441237 -2.704677
2021/07/13           5282.0  0.127563 -0.151346
2021/07/14           6800.0  0.162232 -0.473255
2021/07/15          -2160.0  0.609734  0.405506
2021/07/16           6785.0 -0.158652  0.071389
2021/07/17          15670.0 -0.040378  1.892517
2021/07/18         -10874.0  0.183432  0.536379
2021/07/19         -21186.0 -1.216572 -2.196799
2021/07/20           5835.0 -0.037867 -0.044979
2021/07/21           5728.0  0.508241 -0.487273
2021/07/22          -2299.0  0.052761  0.123404
2021/07/23           6696.0  0.009651  0.157808
2021/07/24          18329.0  0.402513  1.595068
2021/07/25         -10669.0  0.279351  0.608926
2021/07/26         -23269.0 -1.756048 -1.957582
2021/07/27           7910.0  0.374974  0.102941
2021/07/28           7195.0  0.271976 -0.397341
2021/07/29          -1568.0  0.121974  0.071939
2021/07/30           1240.0 -0.323097 -0.009642
2021/07/31          11692.0  0.806326  1.693124
2021/08/01          -1419.0 -0.083921  0.568040
2021/08/02         -23309.0 -1.197897 -1.823121
2021/08/03           6021.0  0.382762 -0.307690
2021/08/04           5184.0  0.224371 -0.159779
2021/08/05          -1820.0  0.213700  0.045172
2021/08/06           2199.0  0.210503  0.053557
2021/08/07          15793.0  0.433313  1.324466
2021/08/08          -6053.0  0.227528  0.915187
2021/08/09         -22049.0 -1.476812 -2.419552
2021/08/10           4498.0  0.864029 -0.313854
2021/08/11           5951.0 -0.361891  0.011769
2021/08/12          -1827.0 -0.178059 -0.032996
2021/08/13           5810.0  0.349272  0.207221
2021/08/14          14591.0  0.313612  1.626783
2021/08/15          -7036.0 -0.030712  0.621387
2021/08/16         -18277.0 -0.492023 -0.229886
2021/08/17           1743.0 -0.320392 -2.102970
2021/08/18          10810.0  0.231022 -0.418104
2021/08/19          -3599.0  0.186924  0.148053
2021/08/20           1624.0  0.140931  0.255090
2021/08/21          24481.0  0.576043  2.264528
2021/08/22          -9835.0 -0.445505  0.305457
2021/08/23         -28924.0 -0.563361 -2.491265
2021/08/24           9165.0  0.635171 -0.388304
2021/08/25           9759.0 -0.326547 -0.162770
2021/08/26          -7134.0  0.101249  0.099862
2021/08/27           3970.0  0.335959  0.163582
2021/08/28          25874.0 -0.250823  1.778201
2021/08/29         -13585.0  0.145392  0.699918
2021/08/30         -28219.0 -0.665134 -2.349837
2021/08/31           4930.0  0.730510 -0.323811
VAR예측모델 생성


C:\Users\USER\anaconda3\lib\site-packages\statsmodels\tsa\base\tsa_model.py:162: ValueWarning: No frequency information was provided, so inferred frequency D will be used.
  % freq, ValueWarning)


AIC 확인

[15.857825738516011, 15.542765651905297, 15.416434613693978, 15.315725629221138, 14.474354911441312, 13.81901076157632, 13.680811498907984, 13.672516129265682, 13.668377252947026, 13.681474829447378, 13.698663519856442, 13.683979739128665, 13.52618800172015, 13.493105460365054, 13.501008939252996, 13.512567749870824, 13.528482798591906, 13.541057001235757, 13.541583886114829, 13.49979072634149, 13.476690198062512, 13.495914939128362, 13.506418609340054, 13.518002310623492, 13.528839763077556, 13.54571761470332, 13.527668591127455, 13.525978459103547, 13.537559244205145]
최적값 확인
  Summary of Regression Results   
==================================
Model:                         VAR
Method:                        OLS
Date:           Tue, 07, Sep, 2021
Time:                     19:08:47
--------------------------------------------------------------------
No. of Equations:         3.00000    BIC:                    14.4841
Nobs:                     891.000    HQIC:                   13.8760
Log likelihood:          -9623.98    FPE:                    729733.
AIC:                      13.4998    Det(Omega_mle):         598255.
--------------------------------------------------------------------
Results for equation ticketing_count
======================================================================================
                         coefficient       std. error           t-stat            prob
--------------------------------------------------------------------------------------
const                     182.415005       226.050794            0.807           0.420
L1.ticketing_count         -0.507607         0.034997          -14.504           0.000
L1.p1                   -1963.674250       855.243540           -2.296           0.022
L1.p2                   -2982.657945       510.765204           -5.840           0.000
L2.ticketing_count         -0.589704         0.039157          -15.060           0.000
L2.p1                   -1253.516652       887.091315           -1.413           0.158
L2.p2                    -653.645229       545.854982           -1.197           0.231
L3.ticketing_count         -0.397659         0.044031           -9.031           0.000
L3.p1                   -1109.836477       904.163434           -1.227           0.220
L3.p2                   -1092.667186       580.947954           -1.881           0.060
L4.ticketing_count         -0.264568         0.045969           -5.755           0.000
L4.p1                    -217.964626       925.257714           -0.236           0.814
L4.p2                   -1299.225958       603.133012           -2.154           0.031
L5.ticketing_count         -0.336628         0.046979           -7.166           0.000
L5.p1                   -1535.347598       932.650252           -1.646           0.100
L5.p2                    -594.066495       627.580977           -0.947           0.344
L6.ticketing_count         -0.096086         0.048402           -1.985           0.047
L6.p1                    -730.384618       947.252195           -0.771           0.441
L6.p2                   -1146.450040       647.043643           -1.772           0.076
L7.ticketing_count          0.160800         0.048490            3.316           0.001
L7.p1                    -270.108129       946.019983           -0.286           0.775
L7.p2                   -1019.057272       660.970318           -1.542           0.123
L8.ticketing_count          0.016185         0.048220            0.336           0.737
L8.p1                    -277.571929       955.693044           -0.290           0.771
L8.p2                     185.285404       657.842817            0.282           0.778
L9.ticketing_count         -0.046925         0.047973           -0.978           0.328
L9.p1                    -540.533657       955.436908           -0.566           0.572
L9.p2                    -584.613659       655.036170           -0.892           0.372
L10.ticketing_count        -0.101683         0.047761           -2.129           0.033
L10.p1                   -270.340581       955.777374           -0.283           0.777
L10.p2                   -603.696531       657.510552           -0.918           0.359
L11.ticketing_count        -0.175075         0.047759           -3.666           0.000
L11.p1                   -453.889348       955.338650           -0.475           0.635
L11.p2                   -165.051357       657.845866           -0.251           0.802
L12.ticketing_count        -0.163646         0.048147           -3.399           0.001
L12.p1                    437.460615       956.397022            0.457           0.647
L12.p2                  -1000.294818       654.942968           -1.527           0.127
L13.ticketing_count        -0.244635         0.048475           -5.047           0.000
L13.p1                   -189.008349       956.415513           -0.198           0.843
L13.p2                   -211.809296       658.430821           -0.322           0.748
L14.ticketing_count         0.065789         0.048886            1.346           0.178
L14.p1                   -786.160421       950.565808           -0.827           0.408
L14.p2                   -314.843714       660.868701           -0.476           0.634
L15.ticketing_count        -0.022360         0.048803           -0.458           0.647
L15.p1                  -1042.730939       951.202213           -1.096           0.273
L15.p2                    333.229924       645.454660            0.516           0.606
L16.ticketing_count        -0.019838         0.047306           -0.419           0.675
L16.p1                    674.513831       939.189592            0.718           0.473
L16.p2                   -882.713310       624.144007           -1.414           0.157
L17.ticketing_count        -0.064715         0.046498           -1.392           0.164
L17.p1                  -2005.577285       924.726381           -2.169           0.030
L17.p2                   -456.501973       606.537953           -0.753           0.452
L18.ticketing_count        -0.129079         0.044416           -2.906           0.004
L18.p1                   -425.894224       907.278730           -0.469           0.639
L18.p2                   -702.569171       583.106596           -1.205           0.228
L19.ticketing_count        -0.123502         0.039436           -3.132           0.002
L19.p1                  -1083.236946       893.072027           -1.213           0.225
L19.p2                  -1103.704648       543.553690           -2.031           0.042
L20.ticketing_count        -0.157841         0.034150           -4.622           0.000
L20.p1                   -469.416448       859.066270           -0.546           0.585
L20.p2                   -512.443612       520.598394           -0.984           0.325
======================================================================================

Results for equation p1
======================================================================================
                         coefficient       std. error           t-stat            prob
--------------------------------------------------------------------------------------
const                       0.020434         0.009635            2.121           0.034
L1.ticketing_count          0.000000         0.000001            0.321           0.748
L1.p1                      -0.302710         0.036452           -8.304           0.000
L1.p2                      -0.116750         0.021770           -5.363           0.000
L2.ticketing_count         -0.000005         0.000002           -2.876           0.004
L2.p1                      -0.205102         0.037809           -5.425           0.000
L2.p2                      -0.018335         0.023265           -0.788           0.431
L3.ticketing_count         -0.000003         0.000002           -1.838           0.066
L3.p1                      -0.238664         0.038537           -6.193           0.000
L3.p2                      -0.044503         0.024761           -1.797           0.072
L4.ticketing_count         -0.000005         0.000002           -2.568           0.010
L4.p1                      -0.146800         0.039436           -3.722           0.000
L4.p2                      -0.069467         0.025707           -2.702           0.007
L5.ticketing_count         -0.000002         0.000002           -1.024           0.306
L5.p1                      -0.208316         0.039751           -5.240           0.000
L5.p2                      -0.023135         0.026749           -0.865           0.387
L6.ticketing_count         -0.000004         0.000002           -1.981           0.048
L6.p1                      -0.105356         0.040374           -2.610           0.009
L6.p2                      -0.040138         0.027578           -1.455           0.146
L7.ticketing_count         -0.000003         0.000002           -1.303           0.193
L7.p1                       0.159834         0.040321            3.964           0.000
L7.p2                       0.013835         0.028172            0.491           0.623
L8.ticketing_count         -0.000002         0.000002           -1.151           0.250
L8.p1                       0.007706         0.040733            0.189           0.850
L8.p2                       0.000464         0.028038            0.017           0.987
L9.ticketing_count         -0.000003         0.000002           -1.647           0.100
L9.p1                      -0.047906         0.040722           -1.176           0.239
L9.p2                      -0.009509         0.027919           -0.341           0.733
L10.ticketing_count         0.000000         0.000002            0.008           0.994
L10.p1                      0.032141         0.040737            0.789           0.430
L10.p2                     -0.033664         0.028024           -1.201           0.230
L11.ticketing_count        -0.000002         0.000002           -0.775           0.438
L11.p1                      0.058923         0.040718            1.447           0.148
L11.p2                     -0.020162         0.028039           -0.719           0.472
L12.ticketing_count        -0.000001         0.000002           -0.594           0.553
L12.p1                      0.041130         0.040763            1.009           0.313
L12.p2                     -0.037590         0.027915           -1.347           0.178
L13.ticketing_count        -0.000000         0.000002           -0.042           0.967
L13.p1                      0.017023         0.040764            0.418           0.676
L13.p2                     -0.045530         0.028063           -1.622           0.105
L14.ticketing_count        -0.000000         0.000002           -0.175           0.861
L14.p1                      0.123573         0.040515            3.050           0.002
L14.p2                      0.022608         0.028167            0.803           0.422
L15.ticketing_count         0.000002         0.000002            0.795           0.427
L15.p1                     -0.018930         0.040542           -0.467           0.641
L15.p2                     -0.001931         0.027510           -0.070           0.944
L16.ticketing_count         0.000002         0.000002            1.005           0.315
L16.p1                     -0.033586         0.040030           -0.839           0.401
L16.p2                     -0.046662         0.026602           -1.754           0.079
L17.ticketing_count         0.000001         0.000002            0.435           0.663
L17.p1                     -0.082311         0.039413           -2.088           0.037
L17.p2                     -0.014665         0.025852           -0.567           0.571
L18.ticketing_count         0.000000         0.000002            0.116           0.908
L18.p1                     -0.100182         0.038670           -2.591           0.010
L18.p2                     -0.030587         0.024853           -1.231           0.218
L19.ticketing_count        -0.000001         0.000002           -0.696           0.486
L19.p1                     -0.109616         0.038064           -2.880           0.004
L19.p2                     -0.007205         0.023167           -0.311           0.756
L20.ticketing_count        -0.000002         0.000001           -1.336           0.181
L20.p1                     -0.120062         0.036615           -3.279           0.001
L20.p2                     -0.017823         0.022189           -0.803           0.422
======================================================================================

Results for equation p2
======================================================================================
                         coefficient       std. error           t-stat            prob
--------------------------------------------------------------------------------------
const                       0.005774         0.016188            0.357           0.721
L1.ticketing_count          0.000002         0.000003            0.843           0.399
L1.p1                      -0.178003         0.061247           -2.906           0.004
L1.p2                      -0.400148         0.036578          -10.940           0.000
L2.ticketing_count         -0.000004         0.000003           -1.289           0.197
L2.p1                       0.072988         0.063528            1.149           0.251
L2.p2                      -0.428868         0.039091          -10.971           0.000
L3.ticketing_count         -0.000004         0.000003           -1.150           0.250
L3.p1                      -0.024023         0.064750           -0.371           0.711
L3.p2                      -0.364706         0.041604           -8.766           0.000
L4.ticketing_count         -0.000002         0.000003           -0.518           0.605
L4.p1                       0.014991         0.066261            0.226           0.821
L4.p2                      -0.391022         0.043192           -9.053           0.000
L5.ticketing_count         -0.000001         0.000003           -0.303           0.762
L5.p1                      -0.102746         0.066790           -1.538           0.124
L5.p2                      -0.323041         0.044943           -7.188           0.000
L6.ticketing_count         -0.000001         0.000003           -0.396           0.692
L6.p1                      -0.036594         0.067836           -0.539           0.590
L6.p2                      -0.278674         0.046337           -6.014           0.000
L7.ticketing_count         -0.000000         0.000003           -0.039           0.969
L7.p1                       0.171858         0.067748            2.537           0.011
L7.p2                      -0.024274         0.047334           -0.513           0.608
L8.ticketing_count         -0.000001         0.000003           -0.174           0.862
L8.p1                      -0.017281         0.068441           -0.252           0.801
L8.p2                      -0.100663         0.047110           -2.137           0.033
L9.ticketing_count          0.000002         0.000003            0.605           0.545
L9.p1                      -0.000261         0.068422           -0.004           0.997
L9.p2                      -0.172523         0.046909           -3.678           0.000
L10.ticketing_count         0.000002         0.000003            0.534           0.594
L10.p1                     -0.007682         0.068447           -0.112           0.911
L10.p2                     -0.105107         0.047087           -2.232           0.026
L11.ticketing_count        -0.000001         0.000003           -0.437           0.662
L11.p1                      0.118395         0.068415            1.731           0.084
L11.p2                     -0.133158         0.047111           -2.827           0.005
L12.ticketing_count        -0.000001         0.000003           -0.350           0.726
L12.p1                      0.053334         0.068491            0.779           0.436
L12.p2                     -0.185461         0.046903           -3.954           0.000
L13.ticketing_count        -0.000001         0.000003           -0.314           0.754
L13.p1                     -0.120939         0.068492           -1.766           0.077
L13.p2                     -0.121771         0.047153           -2.582           0.010
L14.ticketing_count        -0.000000         0.000004           -0.018           0.986
L14.p1                      0.122216         0.068073            1.795           0.073
L14.p2                      0.034106         0.047327            0.721           0.471
L15.ticketing_count        -0.000001         0.000003           -0.418           0.676
L15.p1                     -0.046828         0.068119           -0.687           0.492
L15.p2                     -0.027047         0.046223           -0.585           0.558
L16.ticketing_count         0.000000         0.000003            0.008           0.993
L16.p1                     -0.011780         0.067259           -0.175           0.861
L16.p2                     -0.162745         0.044697           -3.641           0.000
L17.ticketing_count         0.000000         0.000003            0.125           0.901
L17.p1                     -0.153040         0.066223           -2.311           0.021
L17.p2                     -0.111207         0.043436           -2.560           0.010
L18.ticketing_count         0.000000         0.000003            0.068           0.945
L18.p1                     -0.086382         0.064973           -1.329           0.184
L18.p2                     -0.148481         0.041758           -3.556           0.000
L19.ticketing_count        -0.000001         0.000003           -0.529           0.597
L19.p1                     -0.076089         0.063956           -1.190           0.234
L19.p2                     -0.153489         0.038926           -3.943           0.000
L20.ticketing_count         0.000000         0.000002            0.203           0.839
L20.p1                     -0.155479         0.061521           -2.527           0.011
L20.p2                     -0.103581         0.037282           -2.778           0.005
======================================================================================

Correlation matrix of residuals
                   ticketing_count        p1        p2
ticketing_count           1.000000  0.150109  0.182189
p1                        0.150109  1.000000  0.307075
p2                        0.182189  0.307075  1.000000



입력한62일 차분 예측
입력한62일 차분을 더해서 원래값 예측
            ticketing_count        p1        p2  ticketing_count_forecasted  \
date                                                                          
2021/07/01     -2366.997484  0.113782  0.040787                17511.002516   
2021/07/02      3833.721085 -0.046023 -0.006136                21344.723601   
2021/07/03     26999.836743  0.298639  1.033577                48344.560344   
2021/07/04    -13284.011934  0.215947  0.504627                35060.548410   
2021/07/05    -32183.487924 -0.862973 -1.573394                 2877.060486   
2021/07/06      9658.515851  0.181953  0.038405                12535.576337   
2021/07/07      5316.632150  0.047107 -0.087693                17852.208488   
2021/07/08      -476.575575  0.170688  0.138565                17375.632913   
2021/07/09      4126.809111  0.054583  0.086048                21502.442024   
2021/07/10     27094.705933  0.409034  1.098334                48597.147957   
2021/07/11    -14051.007599  0.229965  0.449575                34546.140358   
2021/07/12    -29126.363568 -0.866764 -1.529143                 5419.776790   
2021/07/13      6495.878190  0.106112 -0.049769                11915.654980   
2021/07/14      6503.638647 -0.029069 -0.132196                18419.293627   
2021/07/15      -714.975625  0.157772  0.090307                17704.318001   
2021/07/16      3839.080759 -0.013672 -0.010577                21543.398760   
2021/07/17     25590.214999  0.424779  1.044545                47133.613759   
2021/07/18    -12329.710927  0.216791  0.436696                34803.902832   
2021/07/19    -28986.190510 -0.807407 -1.458906                 5817.712322   
2021/07/20      6374.998342  0.076599 -0.054232                12192.710664   
2021/07/21      6985.820291  0.031220 -0.011946                19178.530955   
2021/07/22     -1352.377754  0.121078  0.045189                17826.153201   
2021/07/23      4217.353433  0.028962  0.042847                22043.506635   
2021/07/24     24420.295789  0.408389  1.012892                46463.802423   
2021/07/25    -12096.724855  0.212282  0.394889                34367.077569   
2021/07/26    -27914.914966 -0.799221 -1.424805                 6452.162602   
2021/07/27      5826.234351  0.033171 -0.111846                12278.396953   
2021/07/28      6725.317441  0.018539 -0.007225                19003.714394   
2021/07/29     -1212.655844  0.107560  0.044138                17791.058549   
2021/07/30      4424.537577  0.042048  0.071379                22215.596126   
2021/07/31     23768.864654  0.436189  1.036518                45984.460781   
2021/08/01    -11761.888940  0.219779  0.411291                34222.571841   
2021/08/02    -26754.818784 -0.753541 -1.365121                 7467.753058   
2021/08/03      5044.840942  0.010209 -0.142776                12512.593999   
2021/08/04      6901.000552  0.021827  0.007042                19413.594551   
2021/08/05     -1437.327958  0.088392  0.008548                17976.266593   
2021/08/06      4634.995460  0.038329  0.056782                22611.262052   
2021/08/07     22616.931159  0.428393  1.007337                45228.193212   
2021/08/08    -11143.823104  0.206121  0.390403                34084.370107   
2021/08/09    -26070.030930 -0.723002 -1.319727                 8014.339178   
2021/08/10      4701.300153 -0.012245 -0.168318                12715.639330   
2021/08/11      6896.855915  0.036731  0.035340                19612.495245   
2021/08/12     -1429.249842  0.079666  0.000541                18183.245404   
2021/08/13      4744.685979  0.050520  0.072811                22927.931383   
2021/08/14     21838.898501  0.428563  0.997045                44766.829884   
2021/08/15    -10819.569570  0.200088  0.379782                33947.260315   
2021/08/16    -25270.624740 -0.696982 -1.282748                 8676.635575   
2021/08/17      4170.880013 -0.034892 -0.207988                12847.515588   
2021/08/18      6869.950390  0.037637  0.038781                19717.465978   
2021/08/19     -1514.512339  0.065638 -0.018953                18202.953639   
2021/08/20      4916.620621  0.051873  0.077705                23119.574260   
2021/08/21     21074.666390  0.427732  0.990731                44194.240650   
2021/08/22    -10388.074586  0.194098  0.381297                33806.166064   
2021/08/23    -24533.493171 -0.665299 -1.231414                 9272.672893   
2021/08/24      3781.285349 -0.049017 -0.227735                13053.958242   
2021/08/25      6857.917700  0.045484  0.051382                19911.875942   
2021/08/26     -1557.157325  0.056682 -0.032935                18354.718617   
2021/08/27      5039.541576  0.054656  0.077764                23394.260194   
2021/08/28     20312.201600  0.421941  0.973380                43706.461794   
2021/08/29    -10014.893444  0.184628  0.370590                33691.568350   
2021/08/30    -23874.739648 -0.640779 -1.191611                 9816.828702   
2021/08/31      3412.998821 -0.064704 -0.251412                13229.827523   

            p1_forecasted  p2_forecasted  
date                                      
2021/07/01       4.294587      -0.967315  
2021/07/02       4.248563      -0.973450  
2021/07/03       4.547202       0.060127  
2021/07/04       4.763149       0.564754  
2021/07/05       3.900176      -1.008640  
2021/07/06       4.082129      -0.970235  
2021/07/07       4.129236      -1.057928  
2021/07/08       4.299924      -0.919363  
2021/07/09       4.354506      -0.833314  
2021/07/10       4.763540       0.265020  
2021/07/11       4.993505       0.714594  
2021/07/12       4.126742      -0.814549  
2021/07/13       4.232853      -0.864318  
2021/07/14       4.203784      -0.996515  
2021/07/15       4.361557      -0.906208  
2021/07/16       4.347885      -0.916785  
2021/07/17       4.772663       0.127760  
2021/07/18       4.989454       0.564456  
2021/07/19       4.182047      -0.894450  
2021/07/20       4.258646      -0.948682  
2021/07/21       4.289866      -0.960628  
2021/07/22       4.410944      -0.915440  
2021/07/23       4.439906      -0.872593  
2021/07/24       4.848294       0.140299  
2021/07/25       5.060576       0.535188  
2021/07/26       4.261356      -0.889617  
2021/07/27       4.294527      -1.001464  
2021/07/28       4.313066      -1.008688  
2021/07/29       4.420625      -0.964550  
2021/07/30       4.462673      -0.893171  
2021/07/31       4.898862       0.143346  
2021/08/01       5.118641       0.554637  
2021/08/02       4.365100      -0.810484  
2021/08/03       4.375309      -0.953260  
2021/08/04       4.397136      -0.946218  
2021/08/05       4.485528      -0.937670  
2021/08/06       4.523857      -0.880887  
2021/08/07       4.952250       0.126450  
2021/08/08       5.158371       0.516853  
2021/08/09       4.435369      -0.802875  
2021/08/10       4.423124      -0.971192  
2021/08/11       4.459855      -0.935852  
2021/08/12       4.539521      -0.935311  
2021/08/13       4.590040      -0.862500  
2021/08/14       5.018603       0.134545  
2021/08/15       5.218692       0.514327  
2021/08/16       4.521710      -0.768420  
2021/08/17       4.486818      -0.976408  
2021/08/18       4.524454      -0.937627  
2021/08/19       4.590092      -0.956580  
2021/08/20       4.641965      -0.878875  
2021/08/21       5.069697       0.111856  
2021/08/22       5.263795       0.493153  
2021/08/23       4.598495      -0.738261  
2021/08/24       4.549478      -0.965996  
2021/08/25       4.594962      -0.914614  
2021/08/26       4.651643      -0.947550  
2021/08/27       4.706299      -0.869785  
2021/08/28       5.128240       0.103595  
2021/08/29       5.312869       0.474185  
2021/08/30       4.672090      -0.717426  
2021/08/31       4.607386      -0.968837  
MSE: 37797203.83872618
RMSE: 6147.943057537715
Variance score: 0.672

#92일치 예측 수행 저장
test,diff = get_result(df,92)
test.to_csv("F:\\drive\\WebWorkPlace2021\\jupyter\\code\\예매건수예측(90일).csv")
차분 전 정상성 평가
ticketing_count
ADF test statistic: -2.099553733500803
p-value: 0.24469408536639126
p1
ADF test statistic: -0.212670087154636
p-value: 0.9369944290580889
p2
ADF test statistic: -0.9660338245209754
p-value: 0.7654502762442534
차분 플롯
차분
            ticketing_count        p1        p2
date                                           
2019/01/02          -2332.0 -0.591827 -1.436540
2019/01/03           1429.0  0.050071  0.043894
2019/01/04            590.0  0.032127 -0.160157
2019/01/05          11667.0  0.453149  0.965645
2019/01/06          -5564.0  0.215044  0.535168
...                     ...       ...       ...
2021/08/27           3970.0  0.335959  0.163582
2021/08/28          25874.0 -0.250823  1.778201
2021/08/29         -13585.0  0.145392  0.699918
2021/08/30         -28219.0 -0.665134 -2.349837
2021/08/31           4930.0  0.730510 -0.323811

[973 rows x 3 columns]
차분 후 정상성 평가
ticketing_count
ADF test statistic: -8.90366524755091
p-value: 1.1532103667357817e-14
p1
ADF test statistic: -7.316333641277955
p-value: 1.2265309592725403e-10
p2
ADF test statistic: -8.654863156313569
p-value: 5.000613197077801e-14
학습, 테스트 데이터 분리
            ticketing_count        p1        p2
date                                           
2019/01/02          -2332.0 -0.591827 -1.436540
2019/01/03           1429.0  0.050071  0.043894
2019/01/04            590.0  0.032127 -0.160157
2019/01/05          11667.0  0.453149  0.965645
2019/01/06          -5564.0  0.215044  0.535168
...                     ...       ...       ...
2021/05/27           -655.0  0.025590  0.119197
2021/05/28           2831.0 -0.018036  0.093058
2021/05/29          25488.0  0.096412  1.349614
2021/05/30         -15747.0  0.175624  0.389396
2021/05/31         -27213.0 -0.680565 -1.806781

[881 rows x 3 columns]             ticketing_count        p1        p2
date                                           
2021/06/01           3597.0  0.504558  0.212486
2021/06/02           8386.0 -0.045186 -0.239367
2021/06/03          -3497.0  0.563131  0.101536
2021/06/04           5764.0 -0.177182  0.128011
2021/06/05          20849.0  0.185960  1.329411
2021/06/06         -10705.0  0.084717  0.494169
2021/06/07         -24991.0 -0.638139 -1.491230
2021/06/08           6444.0  0.201814 -0.185252
2021/06/09           5223.0  0.077752 -0.080977
2021/06/10          -2713.0  0.091582  0.015239
2021/06/11           7851.0 -0.122185 -0.105750
2021/06/12          20693.0  0.184376  1.373220
2021/06/13         -12655.0  0.211366  0.463448
2021/06/14         -25960.0 -0.961899 -1.813409
2021/06/15           7420.0  0.442599  0.205563
2021/06/16           5540.0  0.139153  0.041923
2021/06/17           2553.0  0.089577 -0.113050
2021/06/18           4035.0  0.398201  0.144201
2021/06/19          29447.0 -0.185092  1.139898
2021/06/20         -15918.0  0.162038  0.519437
2021/06/21         -31806.0 -1.126666 -1.680110
2021/06/22           9669.0  0.294151 -0.128855
2021/06/23           4698.0 -0.048134 -0.489230
2021/06/24            659.0  0.466503  0.180801
2021/06/25           2911.0 -0.306558 -0.104249
2021/06/26          30644.0  0.388360  1.257844
2021/06/27         -14777.0  0.219874  0.414628
2021/06/28         -33224.0 -0.868161 -1.371930
2021/06/29           6803.0  0.379811 -0.154252
2021/06/30           9164.0  0.049356  0.075260
2021/07/01          -7908.0 -0.539226 -1.429798
2021/07/02           6262.0  0.176894 -0.161103
2021/07/03          25836.0  0.896067  1.906416
2021/07/04         -11935.0  0.063430  0.781533
2021/07/05         -28317.0 -1.381765 -2.619479
2021/07/06           4418.0  0.438984 -0.023562
2021/07/07           6981.0  0.296948 -0.196619
2021/07/08            -74.0  0.549223  0.449346
2021/07/09           3952.0  0.168500 -0.055949
2021/07/10          12881.0  0.569024  1.851338
2021/07/11          -8866.0  0.812047  0.715844
2021/07/12         -20980.0 -1.441237 -2.704677
2021/07/13           5282.0  0.127563 -0.151346
2021/07/14           6800.0  0.162232 -0.473255
2021/07/15          -2160.0  0.609734  0.405506
2021/07/16           6785.0 -0.158652  0.071389
2021/07/17          15670.0 -0.040378  1.892517
2021/07/18         -10874.0  0.183432  0.536379
2021/07/19         -21186.0 -1.216572 -2.196799
2021/07/20           5835.0 -0.037867 -0.044979
2021/07/21           5728.0  0.508241 -0.487273
2021/07/22          -2299.0  0.052761  0.123404
2021/07/23           6696.0  0.009651  0.157808
2021/07/24          18329.0  0.402513  1.595068
2021/07/25         -10669.0  0.279351  0.608926
2021/07/26         -23269.0 -1.756048 -1.957582
2021/07/27           7910.0  0.374974  0.102941
2021/07/28           7195.0  0.271976 -0.397341
2021/07/29          -1568.0  0.121974  0.071939
2021/07/30           1240.0 -0.323097 -0.009642
2021/07/31          11692.0  0.806326  1.693124
2021/08/01          -1419.0 -0.083921  0.568040
2021/08/02         -23309.0 -1.197897 -1.823121
2021/08/03           6021.0  0.382762 -0.307690
2021/08/04           5184.0  0.224371 -0.159779
2021/08/05          -1820.0  0.213700  0.045172
2021/08/06           2199.0  0.210503  0.053557
2021/08/07          15793.0  0.433313  1.324466
2021/08/08          -6053.0  0.227528  0.915187
2021/08/09         -22049.0 -1.476812 -2.419552
2021/08/10           4498.0  0.864029 -0.313854
2021/08/11           5951.0 -0.361891  0.011769
2021/08/12          -1827.0 -0.178059 -0.032996
2021/08/13           5810.0  0.349272  0.207221
2021/08/14          14591.0  0.313612  1.626783
2021/08/15          -7036.0 -0.030712  0.621387
2021/08/16         -18277.0 -0.492023 -0.229886
2021/08/17           1743.0 -0.320392 -2.102970
2021/08/18          10810.0  0.231022 -0.418104
2021/08/19          -3599.0  0.186924  0.148053
2021/08/20           1624.0  0.140931  0.255090
2021/08/21          24481.0  0.576043  2.264528
2021/08/22          -9835.0 -0.445505  0.305457
2021/08/23         -28924.0 -0.563361 -2.491265
2021/08/24           9165.0  0.635171 -0.388304
2021/08/25           9759.0 -0.326547 -0.162770
2021/08/26          -7134.0  0.101249  0.099862
2021/08/27           3970.0  0.335959  0.163582
2021/08/28          25874.0 -0.250823  1.778201
2021/08/29         -13585.0  0.145392  0.699918
2021/08/30         -28219.0 -0.665134 -2.349837
2021/08/31           4930.0  0.730510 -0.323811
VAR예측모델 생성


C:\Users\USER\anaconda3\lib\site-packages\statsmodels\tsa\base\tsa_model.py:162: ValueWarning: No frequency information was provided, so inferred frequency D will be used.
  % freq, ValueWarning)


AIC 확인

[15.887749080562726, 15.56941157221202, 15.447484531580532, 15.353542527827047, 14.532515718515475, 13.88250706860455, 13.747371575385314, 13.740518436749893, 13.73633567278574, 13.750284608194141, 13.768015273764561, 13.754635710788872, 13.59487413296432, 13.560989601679083, 13.570246134174129, 13.583343147320788, 13.59949595591382, 13.613712798532108, 13.615760459739604, 13.575122086502608, 13.551652624220331, 13.571950947630564, 13.583125371822046, 13.595726243900693, 13.607159400774231, 13.624700389162745, 13.604028071581409, 13.602535608564912, 13.615067562544134]
최적값 확인
  Summary of Regression Results   
==================================
Model:                         VAR
Method:                        OLS
Date:           Tue, 07, Sep, 2021
Time:                     05:11:29
--------------------------------------------------------------------
No. of Equations:         3.00000    BIC:                    14.5864
Nobs:                     861.000    HQIC:                   13.9623
Log likelihood:          -9326.21    FPE:                    786883.
AIC:                      13.5751    Det(Omega_mle):         640807.
--------------------------------------------------------------------
Results for equation ticketing_count
======================================================================================
                         coefficient       std. error           t-stat            prob
--------------------------------------------------------------------------------------
const                     180.028839       232.494775            0.774           0.439
L1.ticketing_count         -0.506965         0.035674          -14.211           0.000
L1.p1                   -1996.120266       876.707419           -2.277           0.023
L1.p2                   -2994.421342       519.469943           -5.764           0.000
L2.ticketing_count         -0.591049         0.039915          -14.808           0.000
L2.p1                   -1282.433066       908.650925           -1.411           0.158
L2.p2                    -632.361889       555.039082           -1.139           0.255
L3.ticketing_count         -0.394801         0.044914           -8.790           0.000
L3.p1                   -1196.789231       927.339100           -1.291           0.197
L3.p2                   -1095.069528       590.695951           -1.854           0.064
L4.ticketing_count         -0.261355         0.046867           -5.577           0.000
L4.p1                    -329.295832       948.482444           -0.347           0.728
L4.p2                   -1277.584888       613.594019           -2.082           0.037
L5.ticketing_count         -0.331604         0.047877           -6.926           0.000
L5.p1                   -1451.385110       955.325162           -1.519           0.129
L5.p2                    -575.436449       638.789387           -0.901           0.368
L6.ticketing_count         -0.092511         0.049281           -1.877           0.060
L6.p1                    -628.070332       970.333321           -0.647           0.517
L6.p2                   -1162.683493       658.884535           -1.765           0.078
L7.ticketing_count          0.161292         0.049347            3.269           0.001
L7.p1                    -167.323245       968.684126           -0.173           0.863
L7.p2                   -1042.236336       672.634705           -1.549           0.121
L8.ticketing_count          0.015200         0.049072            0.310           0.757
L8.p1                    -177.784854       977.960074           -0.182           0.856
L8.p2                     137.289055       669.284746            0.205           0.837
L9.ticketing_count         -0.046776         0.048804           -0.958           0.338
L9.p1                    -600.415419       977.591579           -0.614           0.539
L9.p2                    -558.016498       666.026245           -0.838           0.402
L10.ticketing_count        -0.101711         0.048585           -2.093           0.036
L10.p1                   -287.906427       978.092089           -0.294           0.768
L10.p2                   -666.837544       668.975320           -0.997           0.319
L11.ticketing_count        -0.175435         0.048576           -3.612           0.000
L11.p1                   -582.090970       979.222129           -0.594           0.552
L11.p2                   -131.352511       669.465062           -0.196           0.844
L12.ticketing_count        -0.162653         0.048951           -3.323           0.001
L12.p1                    453.433169       979.924409            0.463           0.644
L12.p2                  -1117.098119       669.825231           -1.668           0.095
L13.ticketing_count        -0.244627         0.049291           -4.963           0.000
L13.p1                   -272.802848       982.249031           -0.278           0.781
L13.p2                   -143.686374       675.792744           -0.213           0.832
L14.ticketing_count         0.068766         0.049694            1.384           0.166
L14.p1                   -740.111283       976.302902           -0.758           0.448
L14.p2                   -428.037568       678.910815           -0.630           0.528
L15.ticketing_count        -0.020000         0.049638           -0.403           0.687
L15.p1                  -1169.538174       978.225955           -1.196           0.232
L15.p2                    419.247354       662.784393            0.633           0.527
L16.ticketing_count        -0.014447         0.048144           -0.300           0.764
L16.p1                    632.082882       966.539034            0.654           0.513
L16.p2                   -966.958352       643.951331           -1.502           0.133
L17.ticketing_count        -0.058850         0.047314           -1.244           0.214
L17.p1                  -2166.603125       951.798396           -2.276           0.023
L17.p2                   -326.016777       625.640090           -0.521           0.602
L18.ticketing_count        -0.124520         0.045196           -2.755           0.006
L18.p1                   -427.503247       935.925604           -0.457           0.648
L18.p2                   -708.220969       603.332673           -1.174           0.240
L19.ticketing_count        -0.118541         0.040125           -2.954           0.003
L19.p1                  -1254.316319       920.116043           -1.363           0.173
L19.p2                  -1055.082102       561.550757           -1.879           0.060
L20.ticketing_count        -0.157318         0.034730           -4.530           0.000
L20.p1                   -374.415333       884.645882           -0.423           0.672
L20.p2                   -594.394189       541.719457           -1.097           0.273
======================================================================================

Results for equation p1
======================================================================================
                         coefficient       std. error           t-stat            prob
--------------------------------------------------------------------------------------
const                       0.019666         0.009854            1.996           0.046
L1.ticketing_count          0.000000         0.000002            0.314           0.754
L1.p1                      -0.299508         0.037157           -8.061           0.000
L1.p2                      -0.115439         0.022016           -5.243           0.000
L2.ticketing_count         -0.000005         0.000002           -2.716           0.007
L2.p1                      -0.208394         0.038510           -5.411           0.000
L2.p2                      -0.017499         0.023524           -0.744           0.457
L3.ticketing_count         -0.000003         0.000002           -1.771           0.077
L3.p1                      -0.236480         0.039302           -6.017           0.000
L3.p2                      -0.046923         0.025035           -1.874           0.061
L4.ticketing_count         -0.000005         0.000002           -2.483           0.013
L4.p1                      -0.143604         0.040199           -3.572           0.000
L4.p2                      -0.069213         0.026005           -2.661           0.008
L5.ticketing_count         -0.000002         0.000002           -1.079           0.280
L5.p1                      -0.204063         0.040489           -5.040           0.000
L5.p2                      -0.023829         0.027073           -0.880           0.379
L6.ticketing_count         -0.000004         0.000002           -1.910           0.056
L6.p1                      -0.108334         0.041125           -2.634           0.008
L6.p2                      -0.037217         0.027925           -1.333           0.183
L7.ticketing_count         -0.000003         0.000002           -1.281           0.200
L7.p1                       0.158004         0.041055            3.849           0.000
L7.p2                       0.013782         0.028508            0.483           0.629
L8.ticketing_count         -0.000002         0.000002           -1.074           0.283
L8.p1                       0.004660         0.041448            0.112           0.910
L8.p2                       0.003852         0.028366            0.136           0.892
L9.ticketing_count         -0.000003         0.000002           -1.607           0.108
L9.p1                      -0.047877         0.041432           -1.156           0.248
L9.p2                      -0.007753         0.028228           -0.275           0.784
L10.ticketing_count        -0.000000         0.000002           -0.077           0.939
L10.p1                      0.040333         0.041453            0.973           0.331
L10.p2                     -0.030906         0.028352           -1.090           0.276
L11.ticketing_count        -0.000002         0.000002           -0.810           0.418
L11.p1                      0.065376         0.041501            1.575           0.115
L11.p2                     -0.022272         0.028373           -0.785           0.432
L12.ticketing_count        -0.000001         0.000002           -0.655           0.512
L12.p1                      0.040571         0.041531            0.977           0.329
L12.p2                     -0.032938         0.028389           -1.160           0.246
L13.ticketing_count        -0.000000         0.000002           -0.097           0.922
L13.p1                      0.028376         0.041630            0.682           0.495
L13.p2                     -0.051221         0.028641           -1.788           0.074
L14.ticketing_count        -0.000000         0.000002           -0.147           0.883
L14.p1                      0.117161         0.041378            2.832           0.005
L14.p2                      0.029178         0.028774            1.014           0.311
L15.ticketing_count         0.000002         0.000002            0.770           0.441
L15.p1                     -0.016478         0.041459           -0.397           0.691
L15.p2                     -0.004837         0.028090           -0.172           0.863
L16.ticketing_count         0.000002         0.000002            1.001           0.317
L16.p1                     -0.033185         0.040964           -0.810           0.418
L16.p2                     -0.047270         0.027292           -1.732           0.083
L17.ticketing_count         0.000001         0.000002            0.477           0.633
L17.p1                     -0.075659         0.040339           -1.876           0.061
L17.p2                     -0.018602         0.026516           -0.702           0.483
L18.ticketing_count         0.000000         0.000002            0.082           0.935
L18.p1                     -0.098411         0.039666           -2.481           0.013
L18.p2                     -0.029382         0.025570           -1.149           0.251
L19.ticketing_count        -0.000001         0.000002           -0.630           0.529
L19.p1                     -0.105450         0.038996           -2.704           0.007
L19.p2                     -0.012101         0.023800           -0.508           0.611
L20.ticketing_count        -0.000002         0.000001           -1.364           0.173
L20.p1                     -0.115861         0.037493           -3.090           0.002
L20.p2                     -0.018901         0.022959           -0.823           0.410
======================================================================================

Results for equation p2
======================================================================================
                         coefficient       std. error           t-stat            prob
--------------------------------------------------------------------------------------
const                       0.005365         0.016665            0.322           0.747
L1.ticketing_count          0.000002         0.000003            0.759           0.448
L1.p1                      -0.176178         0.062840           -2.804           0.005
L1.p2                      -0.399597         0.037234          -10.732           0.000
L2.ticketing_count         -0.000004         0.000003           -1.304           0.192
L2.p1                       0.073331         0.065130            1.126           0.260
L2.p2                      -0.428162         0.039784          -10.762           0.000
L3.ticketing_count         -0.000004         0.000003           -1.121           0.262
L3.p1                      -0.029908         0.066469           -0.450           0.653
L3.p2                      -0.366225         0.042340           -8.650           0.000
L4.ticketing_count         -0.000001         0.000003           -0.443           0.658
L4.p1                       0.002232         0.067985            0.033           0.974
L4.p2                      -0.390555         0.043981           -8.880           0.000
L5.ticketing_count         -0.000001         0.000003           -0.241           0.810
L5.p1                      -0.101401         0.068475           -1.481           0.139
L5.p2                      -0.323031         0.045787           -7.055           0.000
L6.ticketing_count         -0.000001         0.000004           -0.323           0.747
L6.p1                      -0.042435         0.069551           -0.610           0.542
L6.p2                      -0.275340         0.047227           -5.830           0.000
L7.ticketing_count          0.000000         0.000004            0.020           0.984
L7.p1                       0.175276         0.069433            2.524           0.012
L7.p2                      -0.029190         0.048213           -0.605           0.545
L8.ticketing_count         -0.000000         0.000004           -0.141           0.888
L8.p1                      -0.014910         0.070098           -0.213           0.832
L8.p2                      -0.100022         0.047973           -2.085           0.037
L9.ticketing_count          0.000002         0.000003            0.612           0.540
L9.p1                       0.000756         0.070071            0.011           0.991
L9.p2                      -0.174628         0.047739           -3.658           0.000
L10.ticketing_count         0.000002         0.000003            0.513           0.608
L10.p1                     -0.007293         0.070107           -0.104           0.917
L10.p2                     -0.102901         0.047950           -2.146           0.032
L11.ticketing_count        -0.000001         0.000003           -0.419           0.675
L11.p1                      0.119493         0.070188            1.702           0.089
L11.p2                     -0.134612         0.047986           -2.805           0.005
L12.ticketing_count        -0.000001         0.000004           -0.337           0.736
L12.p1                      0.040522         0.070238            0.577           0.564
L12.p2                     -0.179337         0.048011           -3.735           0.000
L13.ticketing_count        -0.000001         0.000004           -0.309           0.758
L13.p1                     -0.113965         0.070405           -1.619           0.106
L13.p2                     -0.128749         0.048439           -2.658           0.008
L14.ticketing_count         0.000000         0.000004            0.006           0.995
L14.p1                      0.120356         0.069979            1.720           0.085
L14.p2                      0.039364         0.048663            0.809           0.419
L15.ticketing_count        -0.000001         0.000004           -0.392           0.695
L15.p1                     -0.047995         0.070117           -0.685           0.494
L15.p2                     -0.028690         0.047507           -0.604           0.546
L16.ticketing_count         0.000000         0.000003            0.075           0.940
L16.p1                     -0.012248         0.069279           -0.177           0.860
L16.p2                     -0.166658         0.046157           -3.611           0.000
L17.ticketing_count         0.000001         0.000003            0.153           0.878
L17.p1                     -0.148408         0.068222           -2.175           0.030
L17.p2                     -0.111562         0.044844           -2.488           0.013
L18.ticketing_count         0.000000         0.000003            0.094           0.925
L18.p1                     -0.089924         0.067085           -1.340           0.180
L18.p2                     -0.144690         0.043245           -3.346           0.001
L19.ticketing_count        -0.000001         0.000003           -0.482           0.630
L19.p1                     -0.075462         0.065952           -1.144           0.253
L19.p2                     -0.156261         0.040251           -3.882           0.000
L20.ticketing_count         0.000001         0.000002            0.259           0.796
L20.p1                     -0.156387         0.063409           -2.466           0.014
L20.p2                     -0.105156         0.038829           -2.708           0.007
======================================================================================

Correlation matrix of residuals
                   ticketing_count        p1        p2
ticketing_count           1.000000  0.155754  0.182997
p1                        0.155754  1.000000  0.305798
p2                        0.182997  0.305798  1.000000



입력한92일 차분 예측
입력한92일 차분을 더해서 원래값 예측
            ticketing_count        p1        p2  ticketing_count_forecasted  \
date                                                                          
2021/06/01     10738.225435  0.003609 -0.181806                14512.225435   
2021/06/02      8272.966484  0.335877  0.610832                22785.191919   
2021/06/03     -5479.580407 -0.098172 -0.418347                17305.611512   
2021/06/04      1976.071958 -0.020856 -0.123805                19281.683471   
2021/06/05     26484.892618  0.429143  1.336143                45766.576089   
2021/06/06    -15567.376928  0.296994  0.578678                30199.199160   
2021/06/07    -26476.727310 -0.749423 -1.750186                 3722.471850   
2021/06/08      9794.489518  0.033773 -0.087741                13516.961368   
2021/06/09     10003.605273  0.254765  0.570758                23520.566641   
2021/06/10     -7649.214317 -0.076366 -0.357663                15871.352323   
2021/06/11      4737.019765  0.019785  0.014513                20608.372088   
2021/06/12     22556.616097  0.333786  1.046902                43164.988185   
2021/06/13    -12497.476873  0.222930  0.430612                30667.511312   
2021/06/14    -27523.550912 -0.800864 -1.675935                 3143.960400   
2021/06/15     10685.501455  0.008486 -0.187669                13829.461856   
2021/06/16      8459.611554  0.287550  0.562890                22289.073410   
2021/06/17     -6097.383683 -0.042078 -0.265213                16191.689726   
2021/06/18      3830.848397  0.040522  0.013506                20022.538124   
2021/06/19     23216.635344  0.412503  1.115534                43239.173468   
2021/06/20    -12949.970584  0.200237  0.419620                30289.202883   
2021/06/21    -26346.463297 -0.780807 -1.572016                 3942.739586   
2021/06/22      9900.652911 -0.028379 -0.204454                13843.392497   
2021/06/23      9418.933605  0.253237  0.515727                23262.326102   
2021/06/24     -7244.168588 -0.081135 -0.295158                16018.157514   
2021/06/25      4114.684594  0.019383 -0.031270                20132.842108   
2021/06/26     22520.506107  0.427033  1.072264                42653.348216   
2021/06/27    -11948.740037  0.206255  0.434432                30704.608179   
2021/06/28    -26369.050329 -0.738613 -1.489838                 4335.557849   
2021/06/29     10025.095468 -0.024260 -0.175833                14360.653318   
2021/06/30      9121.782048  0.262215  0.507920                23482.435366   
2021/07/01     -7062.601179 -0.077727 -0.247359                16419.834187   
2021/07/02      4222.259606  0.026796 -0.027605                20642.093793   
2021/07/03     21676.687141  0.425464  1.039223                42318.780934   
2021/07/04    -11643.511226  0.185593  0.385975                30675.269709   
2021/07/05    -25809.163856 -0.731623 -1.454982                 4866.105853   
2021/07/06      9519.367540 -0.043087 -0.215308                14385.473393   
2021/07/07      9202.855439  0.250935  0.488466                23588.328832   
2021/07/08     -7077.173240 -0.073766 -0.238705                16511.155592   
2021/07/09      4229.318615  0.030127 -0.021233                20740.474207   
2021/07/10     21163.155562  0.441500  1.038095                41903.629769   
2021/07/11    -11245.580736  0.183583  0.390042                30658.049033   
2021/07/12    -25246.380737 -0.699911 -1.393116                 5411.668296   
2021/07/13      9104.203797 -0.053388 -0.223275                14515.872093   
2021/07/14      9275.966984  0.244034  0.466770                23791.839077   
2021/07/15     -7198.016622 -0.081335 -0.245606                16593.822455   
2021/07/16      4271.744895  0.021325 -0.037177                20865.567350   
2021/07/17     20501.461571  0.435268  1.010610                41367.028921   
2021/07/18    -10768.290659  0.174439  0.374575                30598.738262   
2021/07/19    -24754.806081 -0.675964 -1.341104                 5843.932181   
2021/07/20      8776.490705 -0.058631 -0.226528                14620.422886   
2021/07/21      9260.471006  0.243466  0.463311                23880.893892   
2021/07/22     -7073.330982 -0.077082 -0.230704                16807.562910   
2021/07/23      4262.589721  0.022348 -0.033417                21070.152631   
2021/07/24     19988.376734  0.434473  0.996830                41058.529365   
2021/07/25    -10478.903077  0.166010  0.360778                30579.626287   
2021/07/26    -24188.928250 -0.655360 -1.301500                 6390.698037   
2021/07/27      8324.585279 -0.069618 -0.242901                14715.283316   
2021/07/28      9272.885480  0.236394  0.446232                23988.168797   
2021/07/29     -7041.835025 -0.077927 -0.230495                16946.333772   
2021/07/30      4274.862466  0.019763 -0.035025                21221.196237   
2021/07/31     19455.314534  0.432609  0.984250                40676.510771   
2021/08/01    -10113.680681  0.161105  0.356362                30562.830091   
2021/08/02    -23645.012785 -0.630523 -1.253272                 6917.817306   
2021/08/03      7950.453167 -0.074994 -0.247440                14868.270473   
2021/08/04      9234.835311  0.233218  0.435573                24103.105784   
2021/08/05     -6960.708057 -0.077296 -0.228926                17142.397727   
2021/08/06      4232.042110  0.016761 -0.040356                21374.439837   
2021/08/07     18949.873023  0.426759  0.964658                40324.312860   
2021/08/08     -9807.658259  0.153877  0.344480                30516.654601   
2021/08/09    -23108.429677 -0.610128 -1.213529                 7408.224924   
2021/08/10      7565.595084 -0.081201 -0.254337                14973.820007   
2021/08/11      9194.282417  0.229482  0.426791                24168.102424   
2021/08/12     -6853.034486 -0.075063 -0.223570                17315.067938   
2021/08/13      4206.293604  0.015914 -0.039392                21521.361542   
2021/08/14     18484.659841  0.422922  0.950480                40006.021383   
2021/08/15     -9508.716658  0.148672  0.337053                30497.304725   
2021/08/16    -22578.589188 -0.589647 -1.174873                 7918.715536   
2021/08/17      7189.395418 -0.087063 -0.261699                15108.110954   
2021/08/18      9129.420549  0.224775  0.414652                24237.531503   
2021/08/19     -6750.738151 -0.074266 -0.222231                17486.793352   
2021/08/20      4163.987979  0.013748 -0.041944                21650.781331   
2021/08/21     18029.900174  0.417437  0.934285                39680.681505   
2021/08/22     -9214.123481  0.143652  0.330202                30466.558024   
2021/08/23    -22057.270585 -0.569830 -1.136139                 8409.287439   
2021/08/24      6842.063798 -0.091324 -0.265397                15251.351237   
2021/08/25      9052.010363  0.221048  0.405612                24303.361601   
2021/08/26     -6628.683212 -0.072392 -0.218791                17674.678388   
2021/08/27      4111.739041  0.012267 -0.043633                21786.417429   
2021/08/28     17595.798385  0.411670  0.917228                39382.215814   
2021/08/29     -8939.504093  0.138667  0.322110                30442.711721   
2021/08/30    -21551.352960 -0.551612 -1.101251                 8891.358761   
2021/08/31      6499.971448 -0.095724 -0.270115                15391.330209   

            p1_forecasted  p2_forecasted  
date                                      
2021/06/01       3.528737      -1.329321  
2021/06/02       3.864613      -0.718489  
2021/06/03       3.766441      -1.136836  
2021/06/04       3.745586      -1.260641  
2021/06/05       4.174729       0.075502  
2021/06/06       4.471723       0.654180  
2021/06/07       3.722300      -1.096006  
2021/06/08       3.756073      -1.183747  
2021/06/09       4.010837      -0.612989  
2021/06/10       3.934472      -0.970651  
2021/06/11       3.954257      -0.956138  
2021/06/12       4.288043       0.090765  
2021/06/13       4.510973       0.521376  
2021/06/14       3.710109      -1.154558  
2021/06/15       3.718596      -1.342227  
2021/06/16       4.006145      -0.779338  
2021/06/17       3.964068      -1.044550  
2021/06/18       4.004590      -1.031045  
2021/06/19       4.417093       0.084490  
2021/06/20       4.617329       0.504109  
2021/06/21       3.836522      -1.067907  
2021/06/22       3.808143      -1.272360  
2021/06/23       4.061380      -0.756633  
2021/06/24       3.980246      -1.051792  
2021/06/25       3.999629      -1.083061  
2021/06/26       4.426662      -0.010797  
2021/06/27       4.632916       0.423635  
2021/06/28       3.894303      -1.066204  
2021/06/29       3.870043      -1.242037  
2021/06/30       4.132259      -0.734117  
2021/07/01       4.054531      -0.981476  
2021/07/02       4.081327      -1.009081  
2021/07/03       4.506791       0.030142  
2021/07/04       4.692384       0.416117  
2021/07/05       3.960762      -1.038865  
2021/07/06       3.917674      -1.254174  
2021/07/07       4.168610      -0.765707  
2021/07/08       4.094844      -1.004412  
2021/07/09       4.124971      -1.025645  
2021/07/10       4.566471       0.012449  
2021/07/11       4.750054       0.402491  
2021/07/12       4.050143      -0.990625  
2021/07/13       3.996755      -1.213900  
2021/07/14       4.240789      -0.747130  
2021/07/15       4.159454      -0.992736  
2021/07/16       4.180779      -1.029913  
2021/07/17       4.616047      -0.019303  
2021/07/18       4.790485       0.355272  
2021/07/19       4.114521      -0.985832  
2021/07/20       4.055891      -1.212360  
2021/07/21       4.299356      -0.749049  
2021/07/22       4.222274      -0.979753  
2021/07/23       4.244623      -1.013170  
2021/07/24       4.679095      -0.016340  
2021/07/25       4.845105       0.344438  
2021/07/26       4.189745      -0.957062  
2021/07/27       4.120127      -1.199963  
2021/07/28       4.356522      -0.753731  
2021/07/29       4.278595      -0.984226  
2021/07/30       4.298357      -1.019251  
2021/07/31       4.730967      -0.035001  
2021/08/01       4.892072       0.321360  
2021/08/02       4.261548      -0.931912  
2021/08/03       4.186554      -1.179352  
2021/08/04       4.419772      -0.743778  
2021/08/05       4.342476      -0.972704  
2021/08/06       4.359237      -1.013060  
2021/08/07       4.785996      -0.048402  
2021/08/08       4.939873       0.296078  
2021/08/09       4.329745      -0.917450  
2021/08/10       4.248544      -1.171787  
2021/08/11       4.478026      -0.744996  
2021/08/12       4.402963      -0.968566  
2021/08/13       4.418877      -1.007957  
2021/08/14       4.841799      -0.057477  
2021/08/15       4.990471       0.279576  
2021/08/16       4.400823      -0.895298  
2021/08/17       4.313760      -1.156997  
2021/08/18       4.538535      -0.742345  
2021/08/19       4.464269      -0.964576  
2021/08/20       4.478017      -1.006520  
2021/08/21       4.895454      -0.072235  
2021/08/22       5.039106       0.257967  
2021/08/23       4.469276      -0.878172  
2021/08/24       4.377951      -1.143569  
2021/08/25       4.598999      -0.737957  
2021/08/26       4.526608      -0.956748  
2021/08/27       4.538875      -1.000381  
2021/08/28       4.950545      -0.083153  
2021/08/29       5.089213       0.238957  
2021/08/30       4.537601      -0.862294  
2021/08/31       4.441877      -1.132409  
MSE: 25884948.33749545
RMSE: 5087.725261597313
Variance score: 0.809

#모델을 이용하여 앞으로의 예측을 하는 함수 선언(테스트데이터 없음)(진짜 앞으로의 미래 데이터 예측)
#변수로 전처리 및 PCA가 완료된 데이터프레임(df) 및 예측 및 평가를 원하는 일 수(day)를 입력
def get_predict(df, day):
    print("차분 전 정상성 평가")
    for i in df.columns:
        adfuller_test = adfuller(df[i],autolag='AIC')
        print(i)
        print("ADF test statistic: {}".format(adfuller_test[0]))
        print("p-value: {}".format(adfuller_test[1]))

    df_diff = df.diff().dropna()
    print("차분 플롯")
    df_diff.plot(figsize=(20,20))

    print("차분")
    print(df_diff)

    print("차분 후 정상성 평가")
    for i in df.columns:
        adfuller_test = adfuller(df_diff[i],autolag='AIC')
        print(i)
        print("ADF test statistic: {}".format(adfuller_test[0]))
        print("p-value: {}".format(adfuller_test[1]))

    print("학습 데이터 생성 및 예측데이터 담을 인덱스생성")
    train = df_diff
    print(train)
    predict_date = pd.date_range("2021/09/01", periods=day)
    predict_date = predict_date.astype(str)
    predict_date = predict_date.str.split("-").str[0]+"/"+predict_date.str.split("-").str[1]+\
    "/"+predict_date.str.split("-").str[2]
    
    print("VAR예측모델 생성")
    forecasting_model = VAR(train)
    results_aic = []
    for p in range(1,50):
      results = forecasting_model.fit(p)
      results_aic.append(results.aic)

    print("AIC 확인")
    sns.set()
    plt.plot(list(np.arange(1,50,1)), results_aic)
    plt.xlabel("Order")
    plt.ylabel("AIC")
    plt.show()

    print(results_aic)

    print("최적값 확인")
    results = forecasting_model.fit(np.argsort(results_aic)[0])
    results.summary()

    print(f"입력한{day}일 차분 예측")
    laaged_values = train.values
    forecast = pd.DataFrame(results.forecast(y= laaged_values, steps=day), 
                            index = predict_date,
                            columns=df.columns)

    print(f"입력한{day}일 차분을 더해서 원래값 예측")
    for i in df.columns:
        forecast[f'{i}_forecasted']= df[i].iloc[-1]+forecast[i].cumsum()
    print("예측값")
    print(forecast)
    forecast['ticketing_count_forecasted'].plot(figsize=(20,15))
    return forecast
#예매 건수를 정수로 만든 후 저장
#1달치
forecast_ = get_predict(df,30)
forecast_.iloc[:,3:]
forecast_ = forecast_['ticketing_count_forecasted'].round().astype(int)
forecast_.to_csv(f"F:\\drive\\WebWorkPlace2021\\jupyter\\code\\예매건수실전예측(1달).csv")
차분 전 정상성 평가
ticketing_count
ADF test statistic: -2.099553733500803
p-value: 0.24469408536639126
p1
ADF test statistic: -0.21267008715649313
p-value: 0.9369944290578626
p2
ADF test statistic: -0.9660338259001354
p-value: 0.7654502757577035
차분 플롯
차분
            ticketing_count        p1        p2
date                                           
2019/01/02          -2332.0 -0.591827 -1.436540
2019/01/03           1429.0  0.050071  0.043894
2019/01/04            590.0  0.032127 -0.160157
2019/01/05          11667.0  0.453149  0.965645
2019/01/06          -5564.0  0.215044  0.535168
...                     ...       ...       ...
2021/08/27           3970.0  0.335959  0.163582
2021/08/28          25874.0 -0.250823  1.778201
2021/08/29         -13585.0  0.145392  0.699918
2021/08/30         -28219.0 -0.665134 -2.349837
2021/08/31           4930.0  0.730510 -0.323811

[973 rows x 3 columns]
차분 후 정상성 평가
ticketing_count
ADF test statistic: -8.90366524755091
p-value: 1.1532103667357817e-14
p1
ADF test statistic: -7.316333641273258
p-value: 1.2265309593054393e-10
p2
ADF test statistic: -8.654863167499396
p-value: 5.0006128672818535e-14
학습 데이터 생성 및 예측데이터 담을 인덱스생성
            ticketing_count        p1        p2
date                                           
2019/01/02          -2332.0 -0.591827 -1.436540
2019/01/03           1429.0  0.050071  0.043894
2019/01/04            590.0  0.032127 -0.160157
2019/01/05          11667.0  0.453149  0.965645
2019/01/06          -5564.0  0.215044  0.535168
...                     ...       ...       ...
2021/08/27           3970.0  0.335959  0.163582
2021/08/28          25874.0 -0.250823  1.778201
2021/08/29         -13585.0  0.145392  0.699918
2021/08/30         -28219.0 -0.665134 -2.349837
2021/08/31           4930.0  0.730510 -0.323811

[973 rows x 3 columns]
VAR예측모델 생성


C:\Users\USER\anaconda3\lib\site-packages\statsmodels\tsa\base\tsa_model.py:162: ValueWarning: No frequency information was provided, so inferred frequency D will be used.
  % freq, ValueWarning)


AIC 확인

[15.90069559663783, 15.572796595323888, 15.438512269362898, 15.31754572453941, 14.474261894433562, 13.799665066727854, 13.669086564814712, 13.65876525492896, 13.656428475925214, 13.668539921532226, 13.681190675487326, 13.664512252200915, 13.506288204417192, 13.469633668260517, 13.479833314212462, 13.491712686201456, 13.507522473115344, 13.517533721136573, 13.514262134979266, 13.469163895291477, 13.443022659364134, 13.460504604688218, 13.473040467677867, 13.484688931315802, 13.495399070349762, 13.510175068018649, 13.49175709209404, 13.491702356470975, 13.501593114985997, 13.504594156560776, 13.505911140893375, 13.501083244172221, 13.49502634071845, 13.4825402365553, 13.485702287271796, 13.491493702045586, 13.501128156317233, 13.512071363254185, 13.51453437071208, 13.519701052802892, 13.520395791839347, 13.51838091174, 13.529890257546343, 13.54548322923905, 13.557810944948548, 13.577223037311466, 13.585091312860753, 13.584819969570573, 13.587481853395822]
최적값 확인
입력한30일 차분 예측
입력한30일 차분을 더해서 원래값 예측
예측값
            ticketing_count        p1        p2  ticketing_count_forecasted  \
2021/09/01      8379.822447 -0.229706 -0.268557                16961.822447   
2021/09/02     -3013.063096  0.169348  0.169535                13948.759351   
2021/09/03      4792.668778  0.095916  0.373861                18741.428129   
2021/09/04     20225.006527  0.386125  1.704444                38966.434656   
2021/09/05    -10136.242784 -0.067023  0.371076                28830.191872   
2021/09/06    -23969.370043 -0.595097 -1.715073                 4860.821829   
2021/09/07      2207.221154  0.116867 -0.389266                 7068.042983   
2021/09/08      9997.596857 -0.111956 -0.309473                17065.639841   
2021/09/09     -3103.025116  0.169983 -0.047908                13962.614725   
2021/09/10      3497.017794  0.133294  0.476790                17459.632518   
2021/09/11     23318.455698  0.392189  1.695311                40778.088216   
2021/09/12     -9992.588391  0.096094  0.364947                30785.499825   
2021/09/13    -27126.774124 -0.756169 -1.930844                 3658.725702   
2021/09/14      5402.260793  0.162654 -0.177296                 9060.986495   
2021/09/15      7980.389948 -0.093019 -0.274704                17041.376443   
2021/09/16     -2147.577998  0.162500 -0.038151                14893.798445   
2021/09/17      3349.624443  0.125116  0.423708                18243.422888   
2021/09/18     22830.461262  0.361325  1.516753                41073.884149   
2021/09/19    -10955.898071  0.052654  0.258291                30117.986078   
2021/09/20    -24617.505615 -0.769187 -1.710191                 5500.480463   
2021/09/21      3368.053573  0.093730 -0.261761                 8868.534036   
2021/09/22      8424.405369 -0.034282 -0.237434                17292.939405   
2021/09/23     -2691.801564  0.160833 -0.045882                14601.137841   
2021/09/24      4468.807709  0.125172  0.420745                19069.945550   
2021/09/25     21571.036752  0.455940  1.509045                40640.982302   
2021/09/26    -10743.534198  0.061135  0.244850                29897.448104   
2021/09/27    -24241.424586 -0.733965 -1.600000                 5656.023518   
2021/09/28      3576.987366  0.022834 -0.269996                 9233.010884   
2021/09/29      7361.993877 -0.023275 -0.231131                16595.004761   
2021/09/30     -2069.494762  0.124274 -0.086842                14525.509999   

            p1_forecasted  p2_forecasted  
2021/09/01       4.847317      -3.658249  
2021/09/02       5.016665      -3.488714  
2021/09/03       5.112581      -3.114854  
2021/09/04       5.498707      -1.410409  
2021/09/05       5.431684      -1.039333  
2021/09/06       4.836586      -2.754407  
2021/09/07       4.953453      -3.143673  
2021/09/08       4.841497      -3.453146  
2021/09/09       5.011480      -3.501054  
2021/09/10       5.144774      -3.024264  
2021/09/11       5.536963      -1.328953  
2021/09/12       5.633057      -0.964006  
2021/09/13       4.876888      -2.894850  
2021/09/14       5.039541      -3.072146  
2021/09/15       4.946523      -3.346850  
2021/09/16       5.109023      -3.385002  
2021/09/17       5.234139      -2.961294  
2021/09/18       5.595463      -1.444541  
2021/09/19       5.648117      -1.186250  
2021/09/20       4.878930      -2.896441  
2021/09/21       4.972660      -3.158202  
2021/09/22       4.938378      -3.395635  
2021/09/23       5.099211      -3.441517  
2021/09/24       5.224383      -3.020772  
2021/09/25       5.680323      -1.511727  
2021/09/26       5.741458      -1.266877  
2021/09/27       5.007493      -2.866877  
2021/09/28       5.030328      -3.136873  
2021/09/29       5.007053      -3.368004  
2021/09/30       5.131327      -3.454846  

#예매 건수를 정수로 만든 후 저장
#3달치
forecast_ = get_predict(df,92)
forecast_.iloc[:,3:]
forecast_ = forecast_['ticketing_count_forecasted'].round().astype(int)
forecast_.to_csv(f"F:\\drive\\WebWorkPlace2021\\jupyter\\code\\예매건수실전예측(3달).csv")
차분 전 정상성 평가
ticketing_count
ADF test statistic: -2.099553733500803
p-value: 0.24469408536639126
p1
ADF test statistic: -0.21267008715649313
p-value: 0.9369944290578626
p2
ADF test statistic: -0.9660338259001354
p-value: 0.7654502757577035
차분 플롯
차분
            ticketing_count        p1        p2
date                                           
2019/01/02          -2332.0 -0.591827 -1.436540
2019/01/03           1429.0  0.050071  0.043894
2019/01/04            590.0  0.032127 -0.160157
2019/01/05          11667.0  0.453149  0.965645
2019/01/06          -5564.0  0.215044  0.535168
...                     ...       ...       ...
2021/08/27           3970.0  0.335959  0.163582
2021/08/28          25874.0 -0.250823  1.778201
2021/08/29         -13585.0  0.145392  0.699918
2021/08/30         -28219.0 -0.665134 -2.349837
2021/08/31           4930.0  0.730510 -0.323811

[973 rows x 3 columns]
차분 후 정상성 평가
ticketing_count
ADF test statistic: -8.90366524755091
p-value: 1.1532103667357817e-14
p1
ADF test statistic: -7.316333641273258
p-value: 1.2265309593054393e-10
p2
ADF test statistic: -8.654863167499396
p-value: 5.0006128672818535e-14
학습 데이터 생성 및 예측데이터 담을 인덱스생성
            ticketing_count        p1        p2
date                                           
2019/01/02          -2332.0 -0.591827 -1.436540
2019/01/03           1429.0  0.050071  0.043894
2019/01/04            590.0  0.032127 -0.160157
2019/01/05          11667.0  0.453149  0.965645
2019/01/06          -5564.0  0.215044  0.535168
...                     ...       ...       ...
2021/08/27           3970.0  0.335959  0.163582
2021/08/28          25874.0 -0.250823  1.778201
2021/08/29         -13585.0  0.145392  0.699918
2021/08/30         -28219.0 -0.665134 -2.349837
2021/08/31           4930.0  0.730510 -0.323811

[973 rows x 3 columns]
VAR예측모델 생성


C:\Users\USER\anaconda3\lib\site-packages\statsmodels\tsa\base\tsa_model.py:162: ValueWarning: No frequency information was provided, so inferred frequency D will be used.
  % freq, ValueWarning)


AIC 확인

[15.90069559663783, 15.572796595323888, 15.438512269362898, 15.31754572453941, 14.474261894433562, 13.799665066727854, 13.669086564814712, 13.65876525492896, 13.656428475925214, 13.668539921532226, 13.681190675487326, 13.664512252200915, 13.506288204417192, 13.469633668260517, 13.479833314212462, 13.491712686201456, 13.507522473115344, 13.517533721136573, 13.514262134979266, 13.469163895291477, 13.443022659364134, 13.460504604688218, 13.473040467677867, 13.484688931315802, 13.495399070349762, 13.510175068018649, 13.49175709209404, 13.491702356470975, 13.501593114985997, 13.504594156560776, 13.505911140893375, 13.501083244172221, 13.49502634071845, 13.4825402365553, 13.485702287271796, 13.491493702045586, 13.501128156317233, 13.512071363254185, 13.51453437071208, 13.519701052802892, 13.520395791839347, 13.51838091174, 13.529890257546343, 13.54548322923905, 13.557810944948548, 13.577223037311466, 13.585091312860753, 13.584819969570573, 13.587481853395822]
최적값 확인
입력한92일 차분 예측
입력한92일 차분을 더해서 원래값 예측
예측값
            ticketing_count        p1        p2  ticketing_count_forecasted  \
2021/09/01      8379.822447 -0.229706 -0.268557                16961.822447   
2021/09/02     -3013.063096  0.169348  0.169535                13948.759351   
2021/09/03      4792.668778  0.095916  0.373861                18741.428129   
2021/09/04     20225.006527  0.386125  1.704444                38966.434656   
2021/09/05    -10136.242784 -0.067023  0.371076                28830.191872   
2021/09/06    -23969.370043 -0.595097 -1.715073                 4860.821829   
2021/09/07      2207.221154  0.116867 -0.389266                 7068.042983   
2021/09/08      9997.596857 -0.111956 -0.309473                17065.639841   
2021/09/09     -3103.025116  0.169983 -0.047908                13962.614725   
2021/09/10      3497.017794  0.133294  0.476790                17459.632518   
2021/09/11     23318.455698  0.392189  1.695311                40778.088216   
2021/09/12     -9992.588391  0.096094  0.364947                30785.499825   
2021/09/13    -27126.774124 -0.756169 -1.930844                 3658.725702   
2021/09/14      5402.260793  0.162654 -0.177296                 9060.986495   
2021/09/15      7980.389948 -0.093019 -0.274704                17041.376443   
2021/09/16     -2147.577998  0.162500 -0.038151                14893.798445   
2021/09/17      3349.624443  0.125116  0.423708                18243.422888   
2021/09/18     22830.461262  0.361325  1.516753                41073.884149   
2021/09/19    -10955.898071  0.052654  0.258291                30117.986078   
2021/09/20    -24617.505615 -0.769187 -1.710191                 5500.480463   
2021/09/21      3368.053573  0.093730 -0.261761                 8868.534036   
2021/09/22      8424.405369 -0.034282 -0.237434                17292.939405   
2021/09/23     -2691.801564  0.160833 -0.045882                14601.137841   
2021/09/24      4468.807709  0.125172  0.420745                19069.945550   
2021/09/25     21571.036752  0.455940  1.509045                40640.982302   
2021/09/26    -10743.534198  0.061135  0.244850                29897.448104   
2021/09/27    -24241.424586 -0.733965 -1.600000                 5656.023518   
2021/09/28      3576.987366  0.022834 -0.269996                 9233.010884   
2021/09/29      7361.993877 -0.023275 -0.231131                16595.004761   
2021/09/30     -2069.494762  0.124274 -0.086842                14525.509999   
2021/10/01      4572.594305  0.130574  0.416923                19098.104303   
2021/10/02     21339.093057  0.455097  1.450591                40437.197360   
2021/10/03    -10720.175689  0.091146  0.258583                29717.021672   
2021/10/04    -23775.400664 -0.729358 -1.526510                 5941.621008   
2021/10/05      3501.102912  0.012869 -0.276418                 9442.723920   
2021/10/06      7173.454032 -0.005277 -0.190599                16616.177951   
2021/10/07     -1947.297792  0.122153 -0.077097                14668.880159   
2021/10/08      5035.327328  0.131481  0.392593                19704.207487   
2021/10/09     20553.235877  0.467202  1.392806                40257.443364   
2021/10/10    -10834.257426  0.076547  0.240499                29423.185938   
2021/10/11    -22969.411283 -0.714104 -1.458009                 6453.774655   
2021/10/12      3168.146878 -0.025118 -0.315309                 9621.921533   
2021/10/13      6893.794228  0.003841 -0.174083                16515.715762   
2021/10/14     -1901.650353  0.101635 -0.089616                14614.065408   
2021/10/15      5543.145464  0.134759  0.379056                20157.210873   
2021/10/16     19855.822962  0.476856  1.358173                40013.033834   
2021/10/17    -10689.890565  0.082074  0.252778                29323.143269   
2021/10/18    -22491.905380 -0.687695 -1.390863                 6831.237889   
2021/10/19      3069.913079 -0.042919 -0.334210                 9901.150968   
2021/10/20      6463.356482  0.009572 -0.159292                16364.507451   
2021/10/21     -1737.664753  0.085556 -0.102038                14626.842698   
2021/10/22      5840.872891  0.132690  0.356385                20467.715588   
2021/10/23     19257.049654  0.472577  1.314526                39724.765242   
2021/10/24    -10628.591389  0.080870  0.257265                29096.173853   
2021/10/25    -21914.112886 -0.667154 -1.332796                 7182.060967   
2021/10/26      2829.835764 -0.057478 -0.350505                10011.896732   
2021/10/27      6296.239924  0.017496 -0.136921                16308.136655   
2021/10/28     -1650.231408  0.077242 -0.102010                14657.905247   
2021/10/29      6204.642371  0.135877  0.344514                20862.547618   
2021/10/30     18621.592595  0.473049  1.280836                39484.140214   
2021/10/31    -10489.812860  0.079202  0.261551                28994.327354   
2021/11/01    -21421.572569 -0.644187 -1.281574                 7572.754784   
2021/11/02      2625.053683 -0.073407 -0.370973                10197.808467   
2021/11/03      6059.448683  0.021407 -0.125962                16257.257151   
2021/11/04     -1571.490431  0.064985 -0.110383                14685.766719   
2021/11/05      6481.787052  0.135721  0.330192                21167.553772   
2021/11/06     18061.173517  0.468901  1.248786                39228.727289   
2021/11/07    -10322.311122  0.079095  0.268770                28906.416168   
2021/11/08    -20942.333991 -0.621135 -1.230445                 7964.082176   
2021/11/09      2418.838618 -0.083494 -0.383234                10382.920795   
2021/11/10      5862.048042  0.026044 -0.113691                16244.968837   
2021/11/11     -1499.611080  0.056617 -0.116237                14745.357757   
2021/11/12      6705.488707  0.135636  0.316222                21450.846464   
2021/11/13     17520.063499  0.463062  1.215423                38970.909964   
2021/11/14    -10153.340861  0.076888  0.270883                28817.569103   
2021/11/15    -20493.446324 -0.600556 -1.186081                 8324.122779   
2021/11/16      2195.004980 -0.094204 -0.395681                10519.127759   
2021/11/17      5702.602798  0.029444 -0.103217                16221.730558   
2021/11/18     -1434.582380  0.049162 -0.120023                14787.148178   
2021/11/19      6907.817891  0.136226  0.306758                21694.966069   
2021/11/20     17017.254548  0.457738  1.186983                38712.220617   
2021/11/21     -9951.741459  0.075976  0.274589                28760.479158   
2021/11/22    -20066.967115 -0.579754 -1.143143                 8693.512043   
2021/11/23      1982.177266 -0.102993 -0.405984                10675.689309   
2021/11/24      5543.628551  0.032150 -0.095890                16219.317860   
2021/11/25     -1375.853904  0.042150 -0.125312                14843.463956   
2021/11/26      7059.095358  0.135738  0.296523                21902.559315   
2021/11/27     16549.245944  0.450951  1.158437                38451.805259   
2021/11/28     -9742.189888  0.074590  0.276957                28709.615371   
2021/11/29    -19652.604576 -0.560257 -1.102391                 9057.010795   
2021/11/30      1771.321672 -0.110460 -0.413296                10828.332467   
2021/12/01      5405.398584  0.034720 -0.088540                16233.731050   

            p1_forecasted  p2_forecasted  
2021/09/01       4.847317      -3.658249  
2021/09/02       5.016665      -3.488714  
2021/09/03       5.112581      -3.114854  
2021/09/04       5.498707      -1.410409  
2021/09/05       5.431684      -1.039333  
2021/09/06       4.836586      -2.754407  
2021/09/07       4.953453      -3.143673  
2021/09/08       4.841497      -3.453146  
2021/09/09       5.011480      -3.501054  
2021/09/10       5.144774      -3.024264  
2021/09/11       5.536963      -1.328953  
2021/09/12       5.633057      -0.964006  
2021/09/13       4.876888      -2.894850  
2021/09/14       5.039541      -3.072146  
2021/09/15       4.946523      -3.346850  
2021/09/16       5.109023      -3.385002  
2021/09/17       5.234139      -2.961294  
2021/09/18       5.595463      -1.444541  
2021/09/19       5.648117      -1.186250  
2021/09/20       4.878930      -2.896441  
2021/09/21       4.972660      -3.158202  
2021/09/22       4.938378      -3.395635  
2021/09/23       5.099211      -3.441517  
2021/09/24       5.224383      -3.020772  
2021/09/25       5.680323      -1.511727  
2021/09/26       5.741458      -1.266877  
2021/09/27       5.007493      -2.866877  
2021/09/28       5.030328      -3.136873  
2021/09/29       5.007053      -3.368004  
2021/09/30       5.131327      -3.454846  
2021/10/01       5.261901      -3.037923  
2021/10/02       5.716997      -1.587332  
2021/10/03       5.808143      -1.328749  
2021/10/04       5.078785      -2.855259  
2021/10/05       5.091655      -3.131677  
2021/10/06       5.086377      -3.322276  
2021/10/07       5.208530      -3.399374  
2021/10/08       5.340010      -3.006781  
2021/10/09       5.807212      -1.613975  
2021/10/10       5.883759      -1.373475  
2021/10/11       5.169655      -2.831484  
2021/10/12       5.144538      -3.146793  
2021/10/13       5.148378      -3.320876  
2021/10/14       5.250013      -3.410492  
2021/10/15       5.384772      -3.031435  
2021/10/16       5.861629      -1.673262  
2021/10/17       5.943702      -1.420484  
2021/10/18       5.256007      -2.811347  
2021/10/19       5.213087      -3.145557  
2021/10/20       5.222659      -3.304849  
2021/10/21       5.308215      -3.406887  
2021/10/22       5.440905      -3.050502  
2021/10/23       5.913482      -1.735976  
2021/10/24       5.994352      -1.478710  
2021/10/25       5.327198      -2.811506  
2021/10/26       5.269720      -3.162011  
2021/10/27       5.287216      -3.298933  
2021/10/28       5.364458      -3.400943  
2021/10/29       5.500334      -3.056428  
2021/10/30       5.973384      -1.775592  
2021/10/31       6.052586      -1.514041  
2021/11/01       5.408399      -2.795615  
2021/11/02       5.334992      -3.166588  
2021/11/03       5.356399      -3.292550  
2021/11/04       5.421385      -3.402933  
2021/11/05       5.557106      -3.072741  
2021/11/06       6.026006      -1.823955  
2021/11/07       6.105102      -1.555185  
2021/11/08       5.483966      -2.785630  
2021/11/09       5.400472      -3.168864  
2021/11/10       5.426516      -3.282555  
2021/11/11       5.483133      -3.398792  
2021/11/12       5.618770      -3.082571  
2021/11/13       6.081832      -1.867147  
2021/11/14       6.158719      -1.596264  
2021/11/15       5.558163      -2.782345  
2021/11/16       5.463959      -3.178026  
2021/11/17       5.493403      -3.281243  
2021/11/18       5.542564      -3.401266  
2021/11/19       5.678790      -3.094508  
2021/11/20       6.136528      -1.907525  
2021/11/21       6.212504      -1.632936  
2021/11/22       5.632750      -2.776078  
2021/11/23       5.529758      -3.182062  
2021/11/24       5.561907      -3.277952  
2021/11/25       5.604057      -3.403264  
2021/11/26       5.739795      -3.106742  
2021/11/27       6.190746      -1.948305  
2021/11/28       6.265337      -1.671348  
2021/11/29       5.705080      -2.773739  
2021/11/30       5.594620      -3.187035  
2021/12/01       5.629341      -3.275575  

#예매 건수를 정수로 만든 후 저장
#5달치
forecast_ = get_predict(df,153)
forecast_.iloc[:,3:]
forecast_ = forecast_['ticketing_count_forecasted'].round().astype(int)
forecast_.to_csv(f"F:\\drive\\WebWorkPlace2021\\jupyter\\code\\예매건수실전예측(5달).csv")
차분 전 정상성 평가
ticketing_count
ADF test statistic: -2.099553733500803
p-value: 0.24469408536639126
p1
ADF test statistic: -0.21267008715649313
p-value: 0.9369944290578626
p2
ADF test statistic: -0.9660338259001354
p-value: 0.7654502757577035
차분 플롯
차분
            ticketing_count        p1        p2
date                                           
2019/01/02          -2332.0 -0.591827 -1.436540
2019/01/03           1429.0  0.050071  0.043894
2019/01/04            590.0  0.032127 -0.160157
2019/01/05          11667.0  0.453149  0.965645
2019/01/06          -5564.0  0.215044  0.535168
...                     ...       ...       ...
2021/08/27           3970.0  0.335959  0.163582
2021/08/28          25874.0 -0.250823  1.778201
2021/08/29         -13585.0  0.145392  0.699918
2021/08/30         -28219.0 -0.665134 -2.349837
2021/08/31           4930.0  0.730510 -0.323811

[973 rows x 3 columns]
차분 후 정상성 평가
ticketing_count
ADF test statistic: -8.90366524755091
p-value: 1.1532103667357817e-14
p1
ADF test statistic: -7.316333641273258
p-value: 1.2265309593054393e-10
p2
ADF test statistic: -8.654863167499396
p-value: 5.0006128672818535e-14
학습 데이터 생성 및 예측데이터 담을 인덱스생성
            ticketing_count        p1        p2
date                                           
2019/01/02          -2332.0 -0.591827 -1.436540
2019/01/03           1429.0  0.050071  0.043894
2019/01/04            590.0  0.032127 -0.160157
2019/01/05          11667.0  0.453149  0.965645
2019/01/06          -5564.0  0.215044  0.535168
...                     ...       ...       ...
2021/08/27           3970.0  0.335959  0.163582
2021/08/28          25874.0 -0.250823  1.778201
2021/08/29         -13585.0  0.145392  0.699918
2021/08/30         -28219.0 -0.665134 -2.349837
2021/08/31           4930.0  0.730510 -0.323811

[973 rows x 3 columns]
VAR예측모델 생성


C:\Users\USER\anaconda3\lib\site-packages\statsmodels\tsa\base\tsa_model.py:162: ValueWarning: No frequency information was provided, so inferred frequency D will be used.
  % freq, ValueWarning)


AIC 확인

[15.90069559663783, 15.572796595323888, 15.438512269362898, 15.31754572453941, 14.474261894433562, 13.799665066727854, 13.669086564814712, 13.65876525492896, 13.656428475925214, 13.668539921532226, 13.681190675487326, 13.664512252200915, 13.506288204417192, 13.469633668260517, 13.479833314212462, 13.491712686201456, 13.507522473115344, 13.517533721136573, 13.514262134979266, 13.469163895291477, 13.443022659364134, 13.460504604688218, 13.473040467677867, 13.484688931315802, 13.495399070349762, 13.510175068018649, 13.49175709209404, 13.491702356470975, 13.501593114985997, 13.504594156560776, 13.505911140893375, 13.501083244172221, 13.49502634071845, 13.4825402365553, 13.485702287271796, 13.491493702045586, 13.501128156317233, 13.512071363254185, 13.51453437071208, 13.519701052802892, 13.520395791839347, 13.51838091174, 13.529890257546343, 13.54548322923905, 13.557810944948548, 13.577223037311466, 13.585091312860753, 13.584819969570573, 13.587481853395822]
최적값 확인
입력한153일 차분 예측
입력한153일 차분을 더해서 원래값 예측
예측값
            ticketing_count        p1        p2  ticketing_count_forecasted  \
2021/09/01      8379.822447 -0.229706 -0.268557                16961.822447   
2021/09/02     -3013.063096  0.169348  0.169535                13948.759351   
2021/09/03      4792.668778  0.095916  0.373861                18741.428129   
2021/09/04     20225.006527  0.386125  1.704444                38966.434656   
2021/09/05    -10136.242784 -0.067023  0.371076                28830.191872   
2021/09/06    -23969.370043 -0.595097 -1.715073                 4860.821829   
2021/09/07      2207.221154  0.116867 -0.389266                 7068.042983   
2021/09/08      9997.596857 -0.111956 -0.309473                17065.639841   
2021/09/09     -3103.025116  0.169983 -0.047908                13962.614725   
2021/09/10      3497.017794  0.133294  0.476790                17459.632518   
2021/09/11     23318.455698  0.392189  1.695311                40778.088216   
2021/09/12     -9992.588391  0.096094  0.364947                30785.499825   
2021/09/13    -27126.774124 -0.756169 -1.930844                 3658.725702   
2021/09/14      5402.260793  0.162654 -0.177296                 9060.986495   
2021/09/15      7980.389948 -0.093019 -0.274704                17041.376443   
2021/09/16     -2147.577998  0.162500 -0.038151                14893.798445   
2021/09/17      3349.624443  0.125116  0.423708                18243.422888   
2021/09/18     22830.461262  0.361325  1.516753                41073.884149   
2021/09/19    -10955.898071  0.052654  0.258291                30117.986078   
2021/09/20    -24617.505615 -0.769187 -1.710191                 5500.480463   
2021/09/21      3368.053573  0.093730 -0.261761                 8868.534036   
2021/09/22      8424.405369 -0.034282 -0.237434                17292.939405   
2021/09/23     -2691.801564  0.160833 -0.045882                14601.137841   
2021/09/24      4468.807709  0.125172  0.420745                19069.945550   
2021/09/25     21571.036752  0.455940  1.509045                40640.982302   
2021/09/26    -10743.534198  0.061135  0.244850                29897.448104   
2021/09/27    -24241.424586 -0.733965 -1.600000                 5656.023518   
2021/09/28      3576.987366  0.022834 -0.269996                 9233.010884   
2021/09/29      7361.993877 -0.023275 -0.231131                16595.004761   
2021/09/30     -2069.494762  0.124274 -0.086842                14525.509999   
2021/10/01      4572.594305  0.130574  0.416923                19098.104303   
2021/10/02     21339.093057  0.455097  1.450591                40437.197360   
2021/10/03    -10720.175689  0.091146  0.258583                29717.021672   
2021/10/04    -23775.400664 -0.729358 -1.526510                 5941.621008   
2021/10/05      3501.102912  0.012869 -0.276418                 9442.723920   
2021/10/06      7173.454032 -0.005277 -0.190599                16616.177951   
2021/10/07     -1947.297792  0.122153 -0.077097                14668.880159   
2021/10/08      5035.327328  0.131481  0.392593                19704.207487   
2021/10/09     20553.235877  0.467202  1.392806                40257.443364   
2021/10/10    -10834.257426  0.076547  0.240499                29423.185938   
2021/10/11    -22969.411283 -0.714104 -1.458009                 6453.774655   
2021/10/12      3168.146878 -0.025118 -0.315309                 9621.921533   
2021/10/13      6893.794228  0.003841 -0.174083                16515.715762   
2021/10/14     -1901.650353  0.101635 -0.089616                14614.065408   
2021/10/15      5543.145464  0.134759  0.379056                20157.210873   
2021/10/16     19855.822962  0.476856  1.358173                40013.033834   
2021/10/17    -10689.890565  0.082074  0.252778                29323.143269   
2021/10/18    -22491.905380 -0.687695 -1.390863                 6831.237889   
2021/10/19      3069.913079 -0.042919 -0.334210                 9901.150968   
2021/10/20      6463.356482  0.009572 -0.159292                16364.507451   
2021/10/21     -1737.664753  0.085556 -0.102038                14626.842698   
2021/10/22      5840.872891  0.132690  0.356385                20467.715588   
2021/10/23     19257.049654  0.472577  1.314526                39724.765242   
2021/10/24    -10628.591389  0.080870  0.257265                29096.173853   
2021/10/25    -21914.112886 -0.667154 -1.332796                 7182.060967   
2021/10/26      2829.835764 -0.057478 -0.350505                10011.896732   
2021/10/27      6296.239924  0.017496 -0.136921                16308.136655   
2021/10/28     -1650.231408  0.077242 -0.102010                14657.905247   
2021/10/29      6204.642371  0.135877  0.344514                20862.547618   
2021/10/30     18621.592595  0.473049  1.280836                39484.140214   
2021/10/31    -10489.812860  0.079202  0.261551                28994.327354   
2021/11/01    -21421.572569 -0.644187 -1.281574                 7572.754784   
2021/11/02      2625.053683 -0.073407 -0.370973                10197.808467   
2021/11/03      6059.448683  0.021407 -0.125962                16257.257151   
2021/11/04     -1571.490431  0.064985 -0.110383                14685.766719   
2021/11/05      6481.787052  0.135721  0.330192                21167.553772   
2021/11/06     18061.173517  0.468901  1.248786                39228.727289   
2021/11/07    -10322.311122  0.079095  0.268770                28906.416168   
2021/11/08    -20942.333991 -0.621135 -1.230445                 7964.082176   
2021/11/09      2418.838618 -0.083494 -0.383234                10382.920795   
2021/11/10      5862.048042  0.026044 -0.113691                16244.968837   
2021/11/11     -1499.611080  0.056617 -0.116237                14745.357757   
2021/11/12      6705.488707  0.135636  0.316222                21450.846464   
2021/11/13     17520.063499  0.463062  1.215423                38970.909964   
2021/11/14    -10153.340861  0.076888  0.270883                28817.569103   
2021/11/15    -20493.446324 -0.600556 -1.186081                 8324.122779   
2021/11/16      2195.004980 -0.094204 -0.395681                10519.127759   
2021/11/17      5702.602798  0.029444 -0.103217                16221.730558   
2021/11/18     -1434.582380  0.049162 -0.120023                14787.148178   
2021/11/19      6907.817891  0.136226  0.306758                21694.966069   
2021/11/20     17017.254548  0.457738  1.186983                38712.220617   
2021/11/21     -9951.741459  0.075976  0.274589                28760.479158   
2021/11/22    -20066.967115 -0.579754 -1.143143                 8693.512043   
2021/11/23      1982.177266 -0.102993 -0.405984                10675.689309   
2021/11/24      5543.628551  0.032150 -0.095890                16219.317860   
2021/11/25     -1375.853904  0.042150 -0.125312                14843.463956   
2021/11/26      7059.095358  0.135738  0.296523                21902.559315   
2021/11/27     16549.245944  0.450951  1.158437                38451.805259   
2021/11/28     -9742.189888  0.074590  0.276957                28709.615371   
2021/11/29    -19652.604576 -0.560257 -1.102391                 9057.010795   
2021/11/30      1771.321672 -0.110460 -0.413296                10828.332467   
2021/12/01      5405.398584  0.034720 -0.088540                16233.731050   
2021/12/02     -1319.564516  0.036660 -0.128769                14914.166534   
2021/12/03      7182.126635  0.135665  0.288165                22096.293170   
2021/12/04     16105.823350  0.444250  1.131126                38202.116520   
2021/12/05     -9525.019238  0.073267  0.277830                28677.097282   
2021/12/06    -19259.626895 -0.541843 -1.064957                 9417.470387   
2021/12/07      1560.831889 -0.117451 -0.420205                10978.302276   
2021/12/08      5272.281575  0.036442 -0.083307                16250.583851   
2021/12/09     -1266.331349  0.031543 -0.132097                14984.252502   
2021/12/10      7275.398952  0.135325  0.280900                22259.651454   
2021/12/11     15690.542182  0.437359  1.105481                37950.193636   
2021/12/12     -9298.814476  0.072221  0.278789                28651.379159   
2021/12/13    -18876.977915 -0.524080 -1.028860                 9774.401244   
2021/12/14      1357.581466 -0.123307 -0.425235                11131.982710   
2021/12/15      5145.740952  0.037919 -0.079014                16277.723661   
2021/12/16     -1215.165907  0.027186 -0.135085                15062.557754   
2021/12/17      7340.932311  0.134842  0.274011                22403.490065   
2021/12/18     15296.960183  0.430250  1.080334                37700.450249   
2021/12/19     -9069.853995  0.071079  0.278740                28630.596253   
2021/12/20    -18506.184674 -0.507342 -0.994900                10124.411580   
2021/12/21      1159.743914 -0.128568 -0.429103                11284.155493   
2021/12/22      5025.386650  0.038964 -0.075432                16309.542143   
2021/12/23     -1163.881602  0.023430 -0.137230                15145.660541   
2021/12/24      7385.820299  0.134390  0.268173                22531.480840   
2021/12/25     14924.552387  0.423239  1.056404                37456.033228   
2021/12/26     -8837.865848  0.070137  0.278333                28618.167380   
2021/12/27    -18146.023077 -0.491339 -0.962737                10472.144303   
2021/12/28       967.611978 -0.133185 -0.432172                11439.756281   
2021/12/29      4907.230640  0.039602 -0.072935                16346.986920   
2021/12/30     -1113.827629  0.020078 -0.139171                15233.159292   
2021/12/31      7410.184714  0.133775  0.262727                22643.344006   
2022/01/01     14570.460883  0.416170  1.033303                37213.804889   
2022/01/02     -8604.947025  0.069255  0.277625                28608.857864   
2022/01/03    -17794.168636 -0.476078 -0.932016                10814.689228   
2022/01/04       782.608271 -0.137179 -0.434191                11597.297499   
2022/01/05      4792.184127  0.039968 -0.070997                16389.481626   
2022/01/06     -1063.884192  0.017208 -0.140616                15325.597434   
2022/01/07      7417.603206  0.133131  0.257739                22743.200640   
2022/01/08     14232.500629  0.409160  1.010942                36975.701269   
2022/01/09     -8372.768195  0.068453  0.276507                28602.933074   
2022/01/10    -17450.881111 -0.461541 -0.902882                11152.051963   
2022/01/11       604.094429 -0.140688 -0.435541                11756.146392   
2022/01/12      4678.851432  0.040010 -0.069704                16434.997824   
2022/01/13     -1013.962524  0.014686 -0.141659                15421.035300   
2022/01/14      7410.628765  0.132421  0.253199                22831.664065   
2022/01/15     13909.711306  0.402221  0.989430                36741.375370   
2022/01/16     -8141.674337  0.067761  0.275243                28599.701034   
2022/01/17    -17114.791067 -0.447625 -0.875053                11484.909967   
2022/01/18       432.570926 -0.143701 -0.436219                11917.480893   
2022/01/19      4566.802820  0.039805 -0.068967                16484.283714   
2022/01/20      -964.276826  0.012490 -0.142412                15520.006888   
2022/01/21      7390.774849  0.131643  0.248910                22910.781737   
2022/01/22     13600.160789  0.395341  0.968583                36510.942526   
2022/01/23     -7912.924526  0.067133  0.273782                28598.018000   
2022/01/24    -16785.552945 -0.434327 -0.848475                11812.465055   
2022/01/25       268.053241 -0.146290 -0.436292                12080.518296   
2022/01/26      4455.959161  0.039371 -0.068652                16536.477457   
2022/01/27      -914.553270  0.010588 -0.142824                15621.924186   
2022/01/28      7360.165414  0.130823  0.244902                22982.089600   
2022/01/29     13302.829305  0.388557  0.948416                36284.918905   
2022/01/30     -7687.077840  0.066588  0.272187                28597.841065   
2022/01/31    -16462.840285 -0.421590 -0.823079                12135.000780   

            p1_forecasted  p2_forecasted  
2021/09/01       4.847317      -3.658249  
2021/09/02       5.016665      -3.488714  
2021/09/03       5.112581      -3.114854  
2021/09/04       5.498707      -1.410409  
2021/09/05       5.431684      -1.039333  
2021/09/06       4.836586      -2.754407  
2021/09/07       4.953453      -3.143673  
2021/09/08       4.841497      -3.453146  
2021/09/09       5.011480      -3.501054  
2021/09/10       5.144774      -3.024264  
2021/09/11       5.536963      -1.328953  
2021/09/12       5.633057      -0.964006  
2021/09/13       4.876888      -2.894850  
2021/09/14       5.039541      -3.072146  
2021/09/15       4.946523      -3.346850  
2021/09/16       5.109023      -3.385002  
2021/09/17       5.234139      -2.961294  
2021/09/18       5.595463      -1.444541  
2021/09/19       5.648117      -1.186250  
2021/09/20       4.878930      -2.896441  
2021/09/21       4.972660      -3.158202  
2021/09/22       4.938378      -3.395635  
2021/09/23       5.099211      -3.441517  
2021/09/24       5.224383      -3.020772  
2021/09/25       5.680323      -1.511727  
2021/09/26       5.741458      -1.266877  
2021/09/27       5.007493      -2.866877  
2021/09/28       5.030328      -3.136873  
2021/09/29       5.007053      -3.368004  
2021/09/30       5.131327      -3.454846  
2021/10/01       5.261901      -3.037923  
2021/10/02       5.716997      -1.587332  
2021/10/03       5.808143      -1.328749  
2021/10/04       5.078785      -2.855259  
2021/10/05       5.091655      -3.131677  
2021/10/06       5.086377      -3.322276  
2021/10/07       5.208530      -3.399374  
2021/10/08       5.340010      -3.006781  
2021/10/09       5.807212      -1.613975  
2021/10/10       5.883759      -1.373475  
2021/10/11       5.169655      -2.831484  
2021/10/12       5.144538      -3.146793  
2021/10/13       5.148378      -3.320876  
2021/10/14       5.250013      -3.410492  
2021/10/15       5.384772      -3.031435  
2021/10/16       5.861629      -1.673262  
2021/10/17       5.943702      -1.420484  
2021/10/18       5.256007      -2.811347  
2021/10/19       5.213087      -3.145557  
2021/10/20       5.222659      -3.304849  
2021/10/21       5.308215      -3.406887  
2021/10/22       5.440905      -3.050502  
2021/10/23       5.913482      -1.735976  
2021/10/24       5.994352      -1.478710  
2021/10/25       5.327198      -2.811506  
2021/10/26       5.269720      -3.162011  
2021/10/27       5.287216      -3.298933  
2021/10/28       5.364458      -3.400943  
2021/10/29       5.500334      -3.056428  
2021/10/30       5.973384      -1.775592  
2021/10/31       6.052586      -1.514041  
2021/11/01       5.408399      -2.795615  
2021/11/02       5.334992      -3.166588  
2021/11/03       5.356399      -3.292550  
2021/11/04       5.421385      -3.402933  
2021/11/05       5.557106      -3.072741  
2021/11/06       6.026006      -1.823955  
2021/11/07       6.105102      -1.555185  
2021/11/08       5.483966      -2.785630  
2021/11/09       5.400472      -3.168864  
2021/11/10       5.426516      -3.282555  
2021/11/11       5.483133      -3.398792  
2021/11/12       5.618770      -3.082571  
2021/11/13       6.081832      -1.867147  
2021/11/14       6.158719      -1.596264  
2021/11/15       5.558163      -2.782345  
2021/11/16       5.463959      -3.178026  
2021/11/17       5.493403      -3.281243  
2021/11/18       5.542564      -3.401266  
2021/11/19       5.678790      -3.094508  
2021/11/20       6.136528      -1.907525  
2021/11/21       6.212504      -1.632936  
2021/11/22       5.632750      -2.776078  
2021/11/23       5.529758      -3.182062  
2021/11/24       5.561907      -3.277952  
2021/11/25       5.604057      -3.403264  
2021/11/26       5.739795      -3.106742  
2021/11/27       6.190746      -1.948305  
2021/11/28       6.265337      -1.671348  
2021/11/29       5.705080      -2.773739  
2021/11/30       5.594620      -3.187035  
2021/12/01       5.629341      -3.275575  
2021/12/02       5.666001      -3.404344  
2021/12/03       5.801666      -3.116179  
2021/12/04       6.245915      -1.985053  
2021/12/05       6.319182      -1.707223  
2021/12/06       5.777339      -2.772180  
2021/12/07       5.659889      -3.192385  
2021/12/08       5.696331      -3.275692  
2021/12/09       5.727873      -3.407789  
2021/12/10       5.863199      -3.126889  
2021/12/11       6.300558      -2.021408  
2021/12/12       6.372779      -1.742619  
2021/12/13       5.848698      -2.771479  
2021/12/14       5.725391      -3.196714  
2021/12/15       5.763310      -3.275727  
2021/12/16       5.790496      -3.410812  
2021/12/17       5.925339      -3.136801  
2021/12/18       6.355588      -2.056467  
2021/12/19       6.426667      -1.777727  
2021/12/20       5.919325      -2.772628  
2021/12/21       5.790756      -3.201730  
2021/12/22       5.829721      -3.277162  
2021/12/23       5.853151      -3.414392  
2021/12/24       5.987540      -3.146220  
2021/12/25       6.410780      -2.089816  
2021/12/26       6.480917      -1.811483  
2021/12/27       5.989578      -2.774220  
2021/12/28       5.856393      -3.206391  
2021/12/29       5.895995      -3.279326  
2021/12/30       5.916073      -3.418498  
2021/12/31       6.049848      -3.155771  
2022/01/01       6.466018      -2.122468  
2022/01/02       6.535273      -1.844843  
2022/01/03       6.059195      -2.776859  
2022/01/04       5.922016      -3.211051  
2022/01/05       5.961984      -3.282048  
2022/01/06       5.979192      -3.422664  
2022/01/07       6.112323      -3.164925  
2022/01/08       6.521483      -2.153983  
2022/01/09       6.589936      -1.877476  
2022/01/10       6.128395      -2.780358  
2022/01/11       5.987707      -3.215899  
2022/01/12       6.027717      -3.285604  
2022/01/13       6.042403      -3.427262  
2022/01/14       6.174825      -3.174063  
2022/01/15       6.577046      -2.184633  
2022/01/16       6.644807      -1.909390  
2022/01/17       6.197182      -2.784443  
2022/01/18       6.053481      -3.220662  
2022/01/19       6.093285      -3.289629  
2022/01/20       6.105776      -3.432041  
2022/01/21       6.237419      -3.183131  
2022/01/22       6.632761      -2.214548  
2022/01/23       6.699893      -1.940766  
2022/01/24       6.265566      -2.789241  
2022/01/25       6.119276      -3.225533  
2022/01/26       6.158647      -3.294186  
2022/01/27       6.169235      -3.437010  
2022/01/28       6.300059      -3.192108  
2022/01/29       6.688616      -2.243692  
2022/01/30       6.755204      -1.971505  
2022/01/31       6.333615      -2.794584  

좋은 웹페이지 즐겨찾기