वित्तीय डेटा के साथ लीनियर मॉडलिंग

Python में Finance के लिए Machine Learning

Nathan George

Data Science Professor

ट्रेन टेस्ट प्लॉट

Python में Finance के लिए 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 में Finance के लिए Machine Learning

लीनियर मॉडलिंग

model = sm.OLS(train_targets, train_features)

results = model.fit()
Python में Finance के लिए Machine Learning

लीनियर मॉडलिंग

print(results.summary())
Python में Finance के लिए 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 में Finance के लिए Machine Learning

p-values

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 में Finance के लिए Machine Learning

एक्चुअल बनाम एक्चुअल

Python में Finance के लिए Machine Learning

प्रेडिक्शन्स बनाम एक्चुअल

Python में Finance के लिए Machine Learning

अब लीनियर मॉडल फिट करने का समय!

Python में Finance के लिए Machine Learning

Preparing Video For Download...