금융 데이터를 활용한 선형 모델링

Python으로 배우는 금융 분야 Machine Learning

Nathan George

Data Science Professor

훈련/테스트 플롯

Python으로 배우는 금융 분야 Machine Learning

훈련 및 테스트 세트 생성

import statsmodels.api as sm

linear_features = sm.add_constant(features)
train_size = int(0.85 * targets.shape[0])
train_features = linear_features[:train_size] train_targets = targets[:train_size] test_features = linear_features[train_size:] test_targets = targets[train_size:]
some_list[start:stop:step]
Python으로 배우는 금융 분야 Machine Learning

선형 모델링

model = sm.OLS(train_targets, train_features)

results = model.fit()
Python으로 배우는 금융 분야 Machine Learning

선형 모델링

print(results.summary())
Python으로 배우는 금융 분야 Machine Learning
Dep. Variable:         10d_future_pct   R-squared:                  0.157
Model:                            OLS   Adj. R-squared:             0.146
Method:                 Least Squares   F-statistic:                15.55
Date:                Thu, 19 Apr 2018   Prob (F-statistic):         4.79e-14
Time:                        11:41:05   Log-Likelihood:             336.53
No. Observations:                 425   AIC:                       -661.1
Df Residuals:                     419   BIC:                       -636.8
Df Model:                           5                                         
Covariance Type:            nonrobust                                         
===========================================================================
                  coef    std err        t      P>|t|     [0.025     0.975]
<hr />-------------------------------------------------------------------------
const           1.3305      0.323    4.117      0.000      0.695      1.966
10d_close_pct   0.0906      0.098    0.927      0.355     -0.102      0.283
ma14            0.3313      0.209    1.585      0.114     -0.080      0.742
rsi14          -0.0013      0.001   -1.044      0.297     -0.004      0.001
ma200          -0.4090      0.053   -7.712      0.000     -0.513     -0.305
rsi200         -0.0224      0.003   -6.610      0.000     -0.029     -0.016
===========================================================================
Omnibus:                      3.571   Durbin-Watson:              0.209
Prob(Omnibus):                0.168   Jarque-Bera (JB):           3.323
Skew:                         0.202   Prob(JB):                   0.190
Kurtosis:                     3.159   Cond. No.                   5.47e+03
Python으로 배우는 금융 분야 Machine Learning

p-값

print(results.pvalues)
const            4.630428e-05
10d_close_pct    3.546748e-01
ma14             1.136941e-01
rsi14            2.968699e-01
ma200            9.126405e-14
rsi200           1.169324e-10
Python으로 배우는 금융 분야 Machine Learning

실제값 vs 실제값

Python으로 배우는 금융 분야 Machine Learning

예측값 vs 실제값

Python으로 배우는 금융 분야 Machine Learning

이제 선형 모델을 적합해 봅시다!

Python으로 배우는 금융 분야 Machine Learning

Preparing Video For Download...