繁簡切換您正在訪問的是FX168財經網,本網站所提供的內容及信息均遵守中華人民共和國香港特別行政區當地法律法規。

FX168财经网>人物频道>帖子

一:跑回归_多个机器学习模型_对比实验

作者/量化王者 2019-08-02 21:32 0 来源: FX168财经网人物频道
import pandas as pd
df=pd.read_csv('hs2年,季度平均财务数据.csv')
df
.dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; }
Unnamed: 0 eps inc_net_profit_annual inc_operation_profit_annual inc_revenue_annual mean_price net_operate_cash_flow net_profit net_profit_margin operating_profit operating_profit_to_profit operating_revenue retained_profit roe surplus_reserve_fund
0 2016-03-31 0.4253 47.5400 43.3600 10.0800 8.271833 5.926800e+10 6.086000e+09 22.1100 8.014000e+09 87.8300 2.753200e+10 5.901900e+10 3.4900 8.521000e+09
1 2016-06-30 0.3614 1.9700 1.6000 -1.0700 8.370500 -9.246600e+10 6.206000e+09 22.7900 8.142000e+09 86.8100 2.723700e+10 6.303600e+10 3.2700 8.521000e+09
2 2016-09-30 0.3700 3.5600 3.0300 -0.1400 8.921500 -1.197440e+11 6.427000e+09 23.6300 8.389000e+09 462.9000 2.719900e+10 6.946300e+10 3.3000 8.521000e+09
3 2016-12-31 0.2260 -39.6300 -37.6100 -5.3400 8.975500 1.639310e+11 3.880000e+09 15.0700 5.234000e+09 -493.6900 2.574700e+10 6.414300e+10 1.9400 1.078100e+10
4 2017-03-31 0.3619 60.1546 57.2029 7.6320 9.028333 -1.150080e+11 6.214000e+09 22.4235 8.228000e+09 92.3086 2.771200e+10 6.948300e+10 3.0319 1.078100e+10
5 2017-06-30 0.3692 2.0277 0.1458 -4.8751 8.753667 -1.317200e+10 6.340000e+09 24.0507 8.240000e+09 97.5616 2.636100e+10 7.311000e+10 3.0249 1.078100e+10
6 2017-09-30 0.3800 4.0852 3.5437 -2.2799 10.768917 -2.980700e+10 6.599000e+09 25.6172 8.532000e+09 98.0487 2.576000e+10 7.970900e+10 3.0724 1.078100e+10
7 2017-12-31 0.2351 -38.8392 -38.7834 0.7492 12.431917 3.920700e+10 4.036000e+09 15.5512 5.223000e+09 102.8363 2.595300e+10 7.966100e+10 1.8339 1.078100e+10
8 2016-03-31 0.0755 -92.3800 -92.0700 -87.4000 21.820000 -1.072613e+10 1.249823e+09 8.5500 1.646601e+09 74.7700 1.461131e+10 5.343109e+10 0.8300 2.806877e+10
9 2016-06-30 0.4093 367.6500 401.5200 311.9000 21.820000 3.652334e+10 5.844807e+09 9.7100 8.258004e+09 88.0300 6.018398e+10 5.000097e+10 4.5600 2.806877e+10
10 2016-09-30 0.2600 -28.2200 -28.7600 -29.7800 20.037500 1.718868e+10 4.195622e+09 9.9300 5.882695e+09 83.2500 4.225951e+10 5.291205e+10 2.9400 2.806877e+10
11 2016-12-31 1.1559 306.6100 295.0000 192.0600 23.069833 -3.419766e+09 1.706000e+10 13.8200 2.323648e+10 87.8800 1.234224e+11 6.120027e+10 11.9300 3.254077e+10
12 2017-03-31 0.0630 -93.4984 -93.2907 -84.9385 19.356917 -9.523936e+09 1.109171e+09 5.9667 1.559008e+09 82.6764 1.858923e+10 6.189568e+10 0.6116 3.254077e+10
13 2017-06-30 0.5985 706.3518 676.3041 175.5426 19.283500 3.137410e+10 8.943819e+09 17.4611 1.210265e+10 88.4716 5.122125e+10 5.978206e+10 5.8314 3.254077e+10
14 2017-09-30 0.3430 -46.7393 -41.9464 -7.6750 23.069000 -5.143923e+09 4.763538e+09 10.0730 7.026021e+09 72.9184 4.729003e+10 6.357034e+10 3.3083 3.254077e+10
15 2017-12-31 1.5364 370.0679 328.7667 166.0109 27.828917 6.561660e+10 2.239186e+10 17.8001 3.012524e+10 90.1865 1.257966e+11 7.717185e+10 13.6205 3.590007e+10
16 2016-03-31 0.2286 25.6000 344.3000 -30.9700 14.935583 3.945521e+09 1.061152e+09 4.8500 3.142410e+08 31.3500 2.185851e+10 1.462773e+10 3.1800 2.022709e+09
17 2016-06-30 0.1966 6.2200 -42.3500 18.4800 13.704167 -1.590590e+09 1.127202e+09 4.3500 1.811750e+08 -19.1500 2.589879e+10 1.544462e+10 2.6800 2.022709e+09
18 2016-09-30 0.2600 9.3800 152.2100 -8.0800 14.698833 -1.135629e+09 1.232917e+09 5.1800 4.569420e+08 -9.7900 2.380670e+10 1.549858e+10 3.4900 2.022709e+09
19 2016-12-31 -1.2465 -491.6800 -53.3400 24.6300 15.888917 4.040904e+09 -4.829140e+09 -16.2800 2.131900e+08 10.7700 2.966918e+10 1.028224e+10 -17.9600 2.022709e+09
20 2017-03-31 0.2899 127.2813 258.3930 -13.2278 15.712500 -9.711650e+08 1.317453e+09 5.1174 7.640580e+08 44.2163 2.574461e+10 1.149584e+10 4.4960 2.022709e+09
21 2017-06-30 0.2576 -6.9596 231.4621 9.7938 19.197167 -3.235387e+09 1.225763e+09 4.3365 2.532563e+09 75.0814 2.826598e+10 1.257511e+10 3.8153 2.022709e+09
22 2017-09-30 0.3800 42.8370 -21.4213 -20.1544 23.743083 1.036069e+09 1.750843e+09 7.7577 1.990054e+09 -37.8305 2.256914e+10 1.418689e+10 5.3856 2.022709e+09
23 2017-12-31 0.1583 -37.6139 -26.3208 42.8301 34.003917 1.039046e+10 1.092283e+09 3.3884 1.466255e+09 -0.6598 3.223553e+10 1.466768e+10 2.1228 2.205436e+09
24 2016-03-31 0.0732 -73.1400 -69.4400 -62.8300 6.492583 -1.397724e+09 6.400020e+08 11.6400 9.254854e+08 95.1500 5.500350e+09 2.238587e+10 1.5700 2.543815e+09
25 2016-06-30 0.1193 67.2200 48.5900 8.3500 6.177417 6.076731e+08 1.070220e+09 17.9600 1.375193e+09 77.3400 5.959879e+09 2.279104e+10 2.5500 2.543815e+09
26 2016-09-30 0.1630 33.5400 21.4400 27.3400 6.598250 1.097621e+10 1.429121e+09 18.8300 1.670046e+09 93.8000 7.589555e+09 2.412827e+10 3.4200 2.543815e+09
27 2016-12-31 0.4840 191.9000 175.4600 116.5000 6.704000 -5.782313e+09 4.171598e+09 25.3900 4.600311e+09 80.8100 1.643132e+10 2.783806e+10 9.5200 2.805448e+09
28 2017-03-31 0.0923 -80.5276 -75.4480 -62.5386 6.803750 -7.510819e+09 8.123113e+08 13.1967 1.129467e+09 93.1227 6.155396e+09 2.859505e+10 1.7143 2.805448e+09
29 2017-06-30 0.1190 21.9382 29.5916 24.0133 8.113583 -1.018259e+10 9.905180e+08 12.9759 1.463694e+09 96.4607 7.633513e+09 2.876039e+10 2.1770 2.805448e+09
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2252 2016-09-30 0.0800 4422.4400 333.8700 18.7900 25.900667 6.189952e+07 3.913605e+07 2.9600 4.992677e+07 57.8100 1.322482e+09 5.488654e+08 1.7500 9.548766e+07
2253 2016-12-31 0.0980 41.7100 62.7200 5.9500 23.780000 7.941974e+08 5.546059e+07 3.9600 8.124189e+07 138.1700 1.401104e+09 6.000031e+08 1.7100 1.024114e+08
2254 2017-03-31 0.4246 348.5904 316.1423 24.7000 32.809833 -1.637676e+08 2.487909e+08 14.2396 3.380819e+08 100.0001 1.747176e+09 8.516644e+08 5.6251 1.024114e+08
2255 2017-06-30 0.7141 70.6137 48.3772 16.8343 34.699167 -4.569780e+08 4.244713e+08 20.7942 5.016365e+08 97.5342 2.041301e+09 1.274913e+09 8.8329 1.024114e+08
2256 2017-09-30 0.7100 -0.4746 0.6261 15.4893 52.392000 -5.986665e+08 4.224566e+08 17.9198 5.047771e+08 104.4021 2.357484e+09 1.697863e+09 8.2345 1.024114e+08
2257 2017-12-31 1.3458 86.9817 79.7083 48.7714 60.570167 -5.751204e+08 7.899165e+08 22.5223 9.071263e+08 100.5726 3.507261e+09 2.451631e+09 14.1027 1.462961e+08
2258 2017-03-31 0.1338 NaN NaN NaN 82.927500 -1.867580e+08 5.505919e+07 3.8005 6.943522e+07 97.6214 1.448753e+09 1.789010e+09 1.4188 1.243390e+08
2259 2017-06-30 0.8525 551.1253 425.4695 67.4591 107.537750 8.018877e+08 3.585043e+08 14.7772 3.648609e+08 88.9370 2.426069e+09 2.147579e+09 6.8019 1.243390e+08
2260 2017-09-30 1.2900 47.9250 77.3454 24.8382 102.349333 2.840959e+08 5.303175e+08 17.5100 6.470640e+08 97.7817 3.028661e+09 2.678022e+09 9.0454 1.243390e+08
2261 2017-12-31 0.8455 -32.9753 -33.2852 -7.3288 115.926917 9.786372e+08 3.554438e+08 12.6641 4.316878e+08 84.6964 2.806695e+09 2.966904e+09 5.7561 1.910564e+08
2262 2016-12-31 0.7493 -21.6300 -20.4000 -13.8400 78.570484 1.729370e+08 5.119535e+08 15.4300 5.810783e+08 81.1000 3.318619e+09 7.748695e+09 4.8600 3.314493e+08
2263 2017-03-31 0.3262 -56.9138 -54.7474 -26.8197 64.234083 4.605382e+08 2.205816e+08 9.0828 2.629532e+08 92.6879 2.428574e+09 7.971078e+09 1.7487 3.314493e+08
2264 2017-06-30 0.6684 107.1505 116.9275 36.8238 55.238250 8.443235e+08 4.569359e+08 13.7513 5.704178e+08 95.5545 3.322868e+09 7.326335e+09 3.6437 3.314493e+08
2265 2017-09-30 0.6630 -0.9928 -5.6119 11.1736 50.384417 3.536411e+08 4.523996e+08 12.2464 5.384065e+08 99.5631 3.694151e+09 7.778353e+09 3.6427 3.314493e+08
2266 2017-12-31 0.7449 12.5159 -28.2514 19.6033 45.485250 3.034728e+08 5.090213e+08 11.5207 3.862992e+08 60.2863 4.418326e+09 8.276772e+09 3.9406 3.409000e+08
2267 2016-06-30 0.7217 49.1500 22.2700 12.3100 NaN 3.101109e+07 5.469582e+07 15.7800 4.729878e+07 93.4700 3.465495e+08 3.835460e+08 8.5200 2.848906e+07
2268 2016-09-30 0.6600 -0.2500 -2.5200 13.5200 43.327667 3.466695e+07 5.455966e+07 13.8700 4.610903e+07 76.7200 3.934187e+08 4.382496e+08 5.7600 2.848906e+07
2269 2016-12-31 0.3182 -47.2700 -35.0000 11.9500 63.220000 4.948543e+07 2.876988e+07 6.5300 2.997250e+07 86.4600 4.404252e+08 4.526373e+08 2.5300 4.591953e+07
2270 2017-03-31 0.6949 142.0712 151.4006 2.7122 66.899417 -1.276328e+07 6.964360e+07 15.3953 7.535105e+07 95.2615 4.523703e+08 5.221263e+08 5.2954 4.591953e+07
2271 2017-06-30 0.5425 58.7974 65.6053 7.5063 64.560333 1.466835e+08 1.105922e+08 22.7403 1.247853e+08 87.6914 4.863266e+08 5.790817e+08 7.8822 4.591953e+07
2272 2017-09-30 0.8000 44.0255 45.6430 18.9271 64.561333 1.053011e+08 1.592810e+08 27.5394 1.817411e+08 75.2373 5.783742e+08 7.390937e+08 10.5010 4.591953e+07
2273 2017-12-31 0.2860 -63.5692 -69.9259 -11.3657 109.730583 -4.151713e+07 5.802732e+07 11.3194 5.465697e+07 86.3494 5.126378e+08 7.675425e+08 3.4499 7.543034e+07
2274 2016-03-31 0.0084 28.5500 29.3800 13.2200 3.478917 2.648065e+08 1.346673e+08 11.6400 2.324076e+08 85.6200 1.157333e+09 3.128069e+09 0.8100 7.860501e+08
2275 2016-06-30 0.0220 172.4500 63.2700 -4.7400 3.649667 2.701510e+08 3.668949e+08 33.2800 3.794460e+08 66.4800 1.102519e+09 3.076703e+09 2.1300 7.860501e+08
2276 2016-09-30 0.0043 -81.8300 -65.1100 12.1200 3.999250 3.306001e+08 6.664981e+07 5.3900 1.323896e+08 67.1700 1.236185e+09 3.148299e+09 0.4100 7.860501e+08
2277 2016-12-31 0.0245 576.7100 -94.7700 179.3700 3.865833 2.049269e+09 4.510263e+08 13.0600 6.925479e+06 -1.2500 3.453534e+09 3.508789e+09 2.2700 8.400989e+08
2278 2017-03-31 0.0354 121.4284 21460.4199 67.4380 4.363417 1.427245e+09 9.987004e+08 17.2710 1.493162e+09 98.0996 5.782531e+09 4.106009e+09 3.1374 8.400989e+08
2279 2017-06-30 0.0141 -62.8770 -58.4281 1.5543 4.458667 2.054166e+09 3.707473e+08 6.3134 6.207354e+08 155.7238 5.872410e+09 3.752876e+09 1.2508 8.400989e+08
2280 2017-09-30 0.0400 145.8937 114.6130 3.0512 7.000000 2.185045e+09 9.116443e+08 15.0645 1.332179e+09 100.5395 6.051591e+09 4.522277e+09 2.7485 8.400989e+08
2281 2017-12-31 0.0520 44.1926 44.9506 6.4353 6.722417 2.762356e+09 1.314523e+09 20.4086 1.931002e+09 102.5679 6.441026e+09 5.517441e+09 2.9780 9.681907e+08

2282 rows × 15 columns

df.dropna(axis=0, how='any',inplace=True)
df
.dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; }
Unnamed: 0 eps inc_net_profit_annual inc_operation_profit_annual inc_revenue_annual mean_price net_operate_cash_flow net_profit net_profit_margin operating_profit operating_profit_to_profit operating_revenue retained_profit roe surplus_reserve_fund
0 2016-03-31 0.4253 47.5400 43.3600 10.0800 8.271833 5.926800e+10 6.086000e+09 22.1100 8.014000e+09 87.8300 2.753200e+10 5.901900e+10 3.4900 8.521000e+09
1 2016-06-30 0.3614 1.9700 1.6000 -1.0700 8.370500 -9.246600e+10 6.206000e+09 22.7900 8.142000e+09 86.8100 2.723700e+10 6.303600e+10 3.2700 8.521000e+09
2 2016-09-30 0.3700 3.5600 3.0300 -0.1400 8.921500 -1.197440e+11 6.427000e+09 23.6300 8.389000e+09 462.9000 2.719900e+10 6.946300e+10 3.3000 8.521000e+09
3 2016-12-31 0.2260 -39.6300 -37.6100 -5.3400 8.975500 1.639310e+11 3.880000e+09 15.0700 5.234000e+09 -493.6900 2.574700e+10 6.414300e+10 1.9400 1.078100e+10
4 2017-03-31 0.3619 60.1546 57.2029 7.6320 9.028333 -1.150080e+11 6.214000e+09 22.4235 8.228000e+09 92.3086 2.771200e+10 6.948300e+10 3.0319 1.078100e+10
5 2017-06-30 0.3692 2.0277 0.1458 -4.8751 8.753667 -1.317200e+10 6.340000e+09 24.0507 8.240000e+09 97.5616 2.636100e+10 7.311000e+10 3.0249 1.078100e+10
6 2017-09-30 0.3800 4.0852 3.5437 -2.2799 10.768917 -2.980700e+10 6.599000e+09 25.6172 8.532000e+09 98.0487 2.576000e+10 7.970900e+10 3.0724 1.078100e+10
7 2017-12-31 0.2351 -38.8392 -38.7834 0.7492 12.431917 3.920700e+10 4.036000e+09 15.5512 5.223000e+09 102.8363 2.595300e+10 7.966100e+10 1.8339 1.078100e+10
8 2016-03-31 0.0755 -92.3800 -92.0700 -87.4000 21.820000 -1.072613e+10 1.249823e+09 8.5500 1.646601e+09 74.7700 1.461131e+10 5.343109e+10 0.8300 2.806877e+10
9 2016-06-30 0.4093 367.6500 401.5200 311.9000 21.820000 3.652334e+10 5.844807e+09 9.7100 8.258004e+09 88.0300 6.018398e+10 5.000097e+10 4.5600 2.806877e+10
10 2016-09-30 0.2600 -28.2200 -28.7600 -29.7800 20.037500 1.718868e+10 4.195622e+09 9.9300 5.882695e+09 83.2500 4.225951e+10 5.291205e+10 2.9400 2.806877e+10
11 2016-12-31 1.1559 306.6100 295.0000 192.0600 23.069833 -3.419766e+09 1.706000e+10 13.8200 2.323648e+10 87.8800 1.234224e+11 6.120027e+10 11.9300 3.254077e+10
12 2017-03-31 0.0630 -93.4984 -93.2907 -84.9385 19.356917 -9.523936e+09 1.109171e+09 5.9667 1.559008e+09 82.6764 1.858923e+10 6.189568e+10 0.6116 3.254077e+10
13 2017-06-30 0.5985 706.3518 676.3041 175.5426 19.283500 3.137410e+10 8.943819e+09 17.4611 1.210265e+10 88.4716 5.122125e+10 5.978206e+10 5.8314 3.254077e+10
14 2017-09-30 0.3430 -46.7393 -41.9464 -7.6750 23.069000 -5.143923e+09 4.763538e+09 10.0730 7.026021e+09 72.9184 4.729003e+10 6.357034e+10 3.3083 3.254077e+10
15 2017-12-31 1.5364 370.0679 328.7667 166.0109 27.828917 6.561660e+10 2.239186e+10 17.8001 3.012524e+10 90.1865 1.257966e+11 7.717185e+10 13.6205 3.590007e+10
16 2016-03-31 0.2286 25.6000 344.3000 -30.9700 14.935583 3.945521e+09 1.061152e+09 4.8500 3.142410e+08 31.3500 2.185851e+10 1.462773e+10 3.1800 2.022709e+09
17 2016-06-30 0.1966 6.2200 -42.3500 18.4800 13.704167 -1.590590e+09 1.127202e+09 4.3500 1.811750e+08 -19.1500 2.589879e+10 1.544462e+10 2.6800 2.022709e+09
18 2016-09-30 0.2600 9.3800 152.2100 -8.0800 14.698833 -1.135629e+09 1.232917e+09 5.1800 4.569420e+08 -9.7900 2.380670e+10 1.549858e+10 3.4900 2.022709e+09
19 2016-12-31 -1.2465 -491.6800 -53.3400 24.6300 15.888917 4.040904e+09 -4.829140e+09 -16.2800 2.131900e+08 10.7700 2.966918e+10 1.028224e+10 -17.9600 2.022709e+09
20 2017-03-31 0.2899 127.2813 258.3930 -13.2278 15.712500 -9.711650e+08 1.317453e+09 5.1174 7.640580e+08 44.2163 2.574461e+10 1.149584e+10 4.4960 2.022709e+09
21 2017-06-30 0.2576 -6.9596 231.4621 9.7938 19.197167 -3.235387e+09 1.225763e+09 4.3365 2.532563e+09 75.0814 2.826598e+10 1.257511e+10 3.8153 2.022709e+09
22 2017-09-30 0.3800 42.8370 -21.4213 -20.1544 23.743083 1.036069e+09 1.750843e+09 7.7577 1.990054e+09 -37.8305 2.256914e+10 1.418689e+10 5.3856 2.022709e+09
23 2017-12-31 0.1583 -37.6139 -26.3208 42.8301 34.003917 1.039046e+10 1.092283e+09 3.3884 1.466255e+09 -0.6598 3.223553e+10 1.466768e+10 2.1228 2.205436e+09
24 2016-03-31 0.0732 -73.1400 -69.4400 -62.8300 6.492583 -1.397724e+09 6.400020e+08 11.6400 9.254854e+08 95.1500 5.500350e+09 2.238587e+10 1.5700 2.543815e+09
25 2016-06-30 0.1193 67.2200 48.5900 8.3500 6.177417 6.076731e+08 1.070220e+09 17.9600 1.375193e+09 77.3400 5.959879e+09 2.279104e+10 2.5500 2.543815e+09
26 2016-09-30 0.1630 33.5400 21.4400 27.3400 6.598250 1.097621e+10 1.429121e+09 18.8300 1.670046e+09 93.8000 7.589555e+09 2.412827e+10 3.4200 2.543815e+09
27 2016-12-31 0.4840 191.9000 175.4600 116.5000 6.704000 -5.782313e+09 4.171598e+09 25.3900 4.600311e+09 80.8100 1.643132e+10 2.783806e+10 9.5200 2.805448e+09
28 2017-03-31 0.0923 -80.5276 -75.4480 -62.5386 6.803750 -7.510819e+09 8.123113e+08 13.1967 1.129467e+09 93.1227 6.155396e+09 2.859505e+10 1.7143 2.805448e+09
29 2017-06-30 0.1190 21.9382 29.5916 24.0133 8.113583 -1.018259e+10 9.905180e+08 12.9759 1.463694e+09 96.4607 7.633513e+09 2.876039e+10 2.1770 2.805448e+09
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2250 2016-03-31 -0.0652 82.9500 88.2200 26.2300 13.292000 -9.905389e+07 -3.735655e+07 -3.5500 -3.394274e+07 140.0600 1.052482e+09 5.027835e+08 -1.4700 9.548766e+07
2251 2016-06-30 0.0068 102.3200 37.1100 5.7800 20.172750 2.154776e+08 8.653756e+05 0.0800 -2.134785e+07 32.3600 1.113317e+09 5.064022e+08 0.1500 9.548766e+07
2252 2016-09-30 0.0800 4422.4400 333.8700 18.7900 25.900667 6.189952e+07 3.913605e+07 2.9600 4.992677e+07 57.8100 1.322482e+09 5.488654e+08 1.7500 9.548766e+07
2253 2016-12-31 0.0980 41.7100 62.7200 5.9500 23.780000 7.941974e+08 5.546059e+07 3.9600 8.124189e+07 138.1700 1.401104e+09 6.000031e+08 1.7100 1.024114e+08
2254 2017-03-31 0.4246 348.5904 316.1423 24.7000 32.809833 -1.637676e+08 2.487909e+08 14.2396 3.380819e+08 100.0001 1.747176e+09 8.516644e+08 5.6251 1.024114e+08
2255 2017-06-30 0.7141 70.6137 48.3772 16.8343 34.699167 -4.569780e+08 4.244713e+08 20.7942 5.016365e+08 97.5342 2.041301e+09 1.274913e+09 8.8329 1.024114e+08
2256 2017-09-30 0.7100 -0.4746 0.6261 15.4893 52.392000 -5.986665e+08 4.224566e+08 17.9198 5.047771e+08 104.4021 2.357484e+09 1.697863e+09 8.2345 1.024114e+08
2257 2017-12-31 1.3458 86.9817 79.7083 48.7714 60.570167 -5.751204e+08 7.899165e+08 22.5223 9.071263e+08 100.5726 3.507261e+09 2.451631e+09 14.1027 1.462961e+08
2259 2017-06-30 0.8525 551.1253 425.4695 67.4591 107.537750 8.018877e+08 3.585043e+08 14.7772 3.648609e+08 88.9370 2.426069e+09 2.147579e+09 6.8019 1.243390e+08
2260 2017-09-30 1.2900 47.9250 77.3454 24.8382 102.349333 2.840959e+08 5.303175e+08 17.5100 6.470640e+08 97.7817 3.028661e+09 2.678022e+09 9.0454 1.243390e+08
2261 2017-12-31 0.8455 -32.9753 -33.2852 -7.3288 115.926917 9.786372e+08 3.554438e+08 12.6641 4.316878e+08 84.6964 2.806695e+09 2.966904e+09 5.7561 1.910564e+08
2262 2016-12-31 0.7493 -21.6300 -20.4000 -13.8400 78.570484 1.729370e+08 5.119535e+08 15.4300 5.810783e+08 81.1000 3.318619e+09 7.748695e+09 4.8600 3.314493e+08
2263 2017-03-31 0.3262 -56.9138 -54.7474 -26.8197 64.234083 4.605382e+08 2.205816e+08 9.0828 2.629532e+08 92.6879 2.428574e+09 7.971078e+09 1.7487 3.314493e+08
2264 2017-06-30 0.6684 107.1505 116.9275 36.8238 55.238250 8.443235e+08 4.569359e+08 13.7513 5.704178e+08 95.5545 3.322868e+09 7.326335e+09 3.6437 3.314493e+08
2265 2017-09-30 0.6630 -0.9928 -5.6119 11.1736 50.384417 3.536411e+08 4.523996e+08 12.2464 5.384065e+08 99.5631 3.694151e+09 7.778353e+09 3.6427 3.314493e+08
2266 2017-12-31 0.7449 12.5159 -28.2514 19.6033 45.485250 3.034728e+08 5.090213e+08 11.5207 3.862992e+08 60.2863 4.418326e+09 8.276772e+09 3.9406 3.409000e+08
2268 2016-09-30 0.6600 -0.2500 -2.5200 13.5200 43.327667 3.466695e+07 5.455966e+07 13.8700 4.610903e+07 76.7200 3.934187e+08 4.382496e+08 5.7600 2.848906e+07
2269 2016-12-31 0.3182 -47.2700 -35.0000 11.9500 63.220000 4.948543e+07 2.876988e+07 6.5300 2.997250e+07 86.4600 4.404252e+08 4.526373e+08 2.5300 4.591953e+07
2270 2017-03-31 0.6949 142.0712 151.4006 2.7122 66.899417 -1.276328e+07 6.964360e+07 15.3953 7.535105e+07 95.2615 4.523703e+08 5.221263e+08 5.2954 4.591953e+07
2271 2017-06-30 0.5425 58.7974 65.6053 7.5063 64.560333 1.466835e+08 1.105922e+08 22.7403 1.247853e+08 87.6914 4.863266e+08 5.790817e+08 7.8822 4.591953e+07
2272 2017-09-30 0.8000 44.0255 45.6430 18.9271 64.561333 1.053011e+08 1.592810e+08 27.5394 1.817411e+08 75.2373 5.783742e+08 7.390937e+08 10.5010 4.591953e+07
2273 2017-12-31 0.2860 -63.5692 -69.9259 -11.3657 109.730583 -4.151713e+07 5.802732e+07 11.3194 5.465697e+07 86.3494 5.126378e+08 7.675425e+08 3.4499 7.543034e+07
2274 2016-03-31 0.0084 28.5500 29.3800 13.2200 3.478917 2.648065e+08 1.346673e+08 11.6400 2.324076e+08 85.6200 1.157333e+09 3.128069e+09 0.8100 7.860501e+08
2275 2016-06-30 0.0220 172.4500 63.2700 -4.7400 3.649667 2.701510e+08 3.668949e+08 33.2800 3.794460e+08 66.4800 1.102519e+09 3.076703e+09 2.1300 7.860501e+08
2276 2016-09-30 0.0043 -81.8300 -65.1100 12.1200 3.999250 3.306001e+08 6.664981e+07 5.3900 1.323896e+08 67.1700 1.236185e+09 3.148299e+09 0.4100 7.860501e+08
2277 2016-12-31 0.0245 576.7100 -94.7700 179.3700 3.865833 2.049269e+09 4.510263e+08 13.0600 6.925479e+06 -1.2500 3.453534e+09 3.508789e+09 2.2700 8.400989e+08
2278 2017-03-31 0.0354 121.4284 21460.4199 67.4380 4.363417 1.427245e+09 9.987004e+08 17.2710 1.493162e+09 98.0996 5.782531e+09 4.106009e+09 3.1374 8.400989e+08
2279 2017-06-30 0.0141 -62.8770 -58.4281 1.5543 4.458667 2.054166e+09 3.707473e+08 6.3134 6.207354e+08 155.7238 5.872410e+09 3.752876e+09 1.2508 8.400989e+08
2280 2017-09-30 0.0400 145.8937 114.6130 3.0512 7.000000 2.185045e+09 9.116443e+08 15.0645 1.332179e+09 100.5395 6.051591e+09 4.522277e+09 2.7485 8.400989e+08
2281 2017-12-31 0.0520 44.1926 44.9506 6.4353 6.722417 2.762356e+09 1.314523e+09 20.4086 1.931002e+09 102.5679 6.441026e+09 5.517441e+09 2.9780 9.681907e+08

2256 rows × 15 columns

df.set_index('Unnamed: 0', inplace=True) # 再将 列column 改为 index
#df
df
.dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; }
eps inc_net_profit_annual inc_operation_profit_annual inc_revenue_annual mean_price net_operate_cash_flow net_profit net_profit_margin operating_profit operating_profit_to_profit operating_revenue retained_profit roe surplus_reserve_fund
Unnamed: 0
2016-03-31 0.4253 47.5400 43.3600 10.0800 8.271833 5.926800e+10 6.086000e+09 22.1100 8.014000e+09 87.8300 2.753200e+10 5.901900e+10 3.4900 8.521000e+09
2016-06-30 0.3614 1.9700 1.6000 -1.0700 8.370500 -9.246600e+10 6.206000e+09 22.7900 8.142000e+09 86.8100 2.723700e+10 6.303600e+10 3.2700 8.521000e+09
2016-09-30 0.3700 3.5600 3.0300 -0.1400 8.921500 -1.197440e+11 6.427000e+09 23.6300 8.389000e+09 462.9000 2.719900e+10 6.946300e+10 3.3000 8.521000e+09
2016-12-31 0.2260 -39.6300 -37.6100 -5.3400 8.975500 1.639310e+11 3.880000e+09 15.0700 5.234000e+09 -493.6900 2.574700e+10 6.414300e+10 1.9400 1.078100e+10
2017-03-31 0.3619 60.1546 57.2029 7.6320 9.028333 -1.150080e+11 6.214000e+09 22.4235 8.228000e+09 92.3086 2.771200e+10 6.948300e+10 3.0319 1.078100e+10
2017-06-30 0.3692 2.0277 0.1458 -4.8751 8.753667 -1.317200e+10 6.340000e+09 24.0507 8.240000e+09 97.5616 2.636100e+10 7.311000e+10 3.0249 1.078100e+10
2017-09-30 0.3800 4.0852 3.5437 -2.2799 10.768917 -2.980700e+10 6.599000e+09 25.6172 8.532000e+09 98.0487 2.576000e+10 7.970900e+10 3.0724 1.078100e+10
2017-12-31 0.2351 -38.8392 -38.7834 0.7492 12.431917 3.920700e+10 4.036000e+09 15.5512 5.223000e+09 102.8363 2.595300e+10 7.966100e+10 1.8339 1.078100e+10
2016-03-31 0.0755 -92.3800 -92.0700 -87.4000 21.820000 -1.072613e+10 1.249823e+09 8.5500 1.646601e+09 74.7700 1.461131e+10 5.343109e+10 0.8300 2.806877e+10
2016-06-30 0.4093 367.6500 401.5200 311.9000 21.820000 3.652334e+10 5.844807e+09 9.7100 8.258004e+09 88.0300 6.018398e+10 5.000097e+10 4.5600 2.806877e+10
2016-09-30 0.2600 -28.2200 -28.7600 -29.7800 20.037500 1.718868e+10 4.195622e+09 9.9300 5.882695e+09 83.2500 4.225951e+10 5.291205e+10 2.9400 2.806877e+10
2016-12-31 1.1559 306.6100 295.0000 192.0600 23.069833 -3.419766e+09 1.706000e+10 13.8200 2.323648e+10 87.8800 1.234224e+11 6.120027e+10 11.9300 3.254077e+10
2017-03-31 0.0630 -93.4984 -93.2907 -84.9385 19.356917 -9.523936e+09 1.109171e+09 5.9667 1.559008e+09 82.6764 1.858923e+10 6.189568e+10 0.6116 3.254077e+10
2017-06-30 0.5985 706.3518 676.3041 175.5426 19.283500 3.137410e+10 8.943819e+09 17.4611 1.210265e+10 88.4716 5.122125e+10 5.978206e+10 5.8314 3.254077e+10
2017-09-30 0.3430 -46.7393 -41.9464 -7.6750 23.069000 -5.143923e+09 4.763538e+09 10.0730 7.026021e+09 72.9184 4.729003e+10 6.357034e+10 3.3083 3.254077e+10
2017-12-31 1.5364 370.0679 328.7667 166.0109 27.828917 6.561660e+10 2.239186e+10 17.8001 3.012524e+10 90.1865 1.257966e+11 7.717185e+10 13.6205 3.590007e+10
2016-03-31 0.2286 25.6000 344.3000 -30.9700 14.935583 3.945521e+09 1.061152e+09 4.8500 3.142410e+08 31.3500 2.185851e+10 1.462773e+10 3.1800 2.022709e+09
2016-06-30 0.1966 6.2200 -42.3500 18.4800 13.704167 -1.590590e+09 1.127202e+09 4.3500 1.811750e+08 -19.1500 2.589879e+10 1.544462e+10 2.6800 2.022709e+09
2016-09-30 0.2600 9.3800 152.2100 -8.0800 14.698833 -1.135629e+09 1.232917e+09 5.1800 4.569420e+08 -9.7900 2.380670e+10 1.549858e+10 3.4900 2.022709e+09
2016-12-31 -1.2465 -491.6800 -53.3400 24.6300 15.888917 4.040904e+09 -4.829140e+09 -16.2800 2.131900e+08 10.7700 2.966918e+10 1.028224e+10 -17.9600 2.022709e+09
2017-03-31 0.2899 127.2813 258.3930 -13.2278 15.712500 -9.711650e+08 1.317453e+09 5.1174 7.640580e+08 44.2163 2.574461e+10 1.149584e+10 4.4960 2.022709e+09
2017-06-30 0.2576 -6.9596 231.4621 9.7938 19.197167 -3.235387e+09 1.225763e+09 4.3365 2.532563e+09 75.0814 2.826598e+10 1.257511e+10 3.8153 2.022709e+09
2017-09-30 0.3800 42.8370 -21.4213 -20.1544 23.743083 1.036069e+09 1.750843e+09 7.7577 1.990054e+09 -37.8305 2.256914e+10 1.418689e+10 5.3856 2.022709e+09
2017-12-31 0.1583 -37.6139 -26.3208 42.8301 34.003917 1.039046e+10 1.092283e+09 3.3884 1.466255e+09 -0.6598 3.223553e+10 1.466768e+10 2.1228 2.205436e+09
2016-03-31 0.0732 -73.1400 -69.4400 -62.8300 6.492583 -1.397724e+09 6.400020e+08 11.6400 9.254854e+08 95.1500 5.500350e+09 2.238587e+10 1.5700 2.543815e+09
2016-06-30 0.1193 67.2200 48.5900 8.3500 6.177417 6.076731e+08 1.070220e+09 17.9600 1.375193e+09 77.3400 5.959879e+09 2.279104e+10 2.5500 2.543815e+09
2016-09-30 0.1630 33.5400 21.4400 27.3400 6.598250 1.097621e+10 1.429121e+09 18.8300 1.670046e+09 93.8000 7.589555e+09 2.412827e+10 3.4200 2.543815e+09
2016-12-31 0.4840 191.9000 175.4600 116.5000 6.704000 -5.782313e+09 4.171598e+09 25.3900 4.600311e+09 80.8100 1.643132e+10 2.783806e+10 9.5200 2.805448e+09
2017-03-31 0.0923 -80.5276 -75.4480 -62.5386 6.803750 -7.510819e+09 8.123113e+08 13.1967 1.129467e+09 93.1227 6.155396e+09 2.859505e+10 1.7143 2.805448e+09
2017-06-30 0.1190 21.9382 29.5916 24.0133 8.113583 -1.018259e+10 9.905180e+08 12.9759 1.463694e+09 96.4607 7.633513e+09 2.876039e+10 2.1770 2.805448e+09
... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2016-03-31 -0.0652 82.9500 88.2200 26.2300 13.292000 -9.905389e+07 -3.735655e+07 -3.5500 -3.394274e+07 140.0600 1.052482e+09 5.027835e+08 -1.4700 9.548766e+07
2016-06-30 0.0068 102.3200 37.1100 5.7800 20.172750 2.154776e+08 8.653756e+05 0.0800 -2.134785e+07 32.3600 1.113317e+09 5.064022e+08 0.1500 9.548766e+07
2016-09-30 0.0800 4422.4400 333.8700 18.7900 25.900667 6.189952e+07 3.913605e+07 2.9600 4.992677e+07 57.8100 1.322482e+09 5.488654e+08 1.7500 9.548766e+07
2016-12-31 0.0980 41.7100 62.7200 5.9500 23.780000 7.941974e+08 5.546059e+07 3.9600 8.124189e+07 138.1700 1.401104e+09 6.000031e+08 1.7100 1.024114e+08
2017-03-31 0.4246 348.5904 316.1423 24.7000 32.809833 -1.637676e+08 2.487909e+08 14.2396 3.380819e+08 100.0001 1.747176e+09 8.516644e+08 5.6251 1.024114e+08
2017-06-30 0.7141 70.6137 48.3772 16.8343 34.699167 -4.569780e+08 4.244713e+08 20.7942 5.016365e+08 97.5342 2.041301e+09 1.274913e+09 8.8329 1.024114e+08
2017-09-30 0.7100 -0.4746 0.6261 15.4893 52.392000 -5.986665e+08 4.224566e+08 17.9198 5.047771e+08 104.4021 2.357484e+09 1.697863e+09 8.2345 1.024114e+08
2017-12-31 1.3458 86.9817 79.7083 48.7714 60.570167 -5.751204e+08 7.899165e+08 22.5223 9.071263e+08 100.5726 3.507261e+09 2.451631e+09 14.1027 1.462961e+08
2017-06-30 0.8525 551.1253 425.4695 67.4591 107.537750 8.018877e+08 3.585043e+08 14.7772 3.648609e+08 88.9370 2.426069e+09 2.147579e+09 6.8019 1.243390e+08
2017-09-30 1.2900 47.9250 77.3454 24.8382 102.349333 2.840959e+08 5.303175e+08 17.5100 6.470640e+08 97.7817 3.028661e+09 2.678022e+09 9.0454 1.243390e+08
2017-12-31 0.8455 -32.9753 -33.2852 -7.3288 115.926917 9.786372e+08 3.554438e+08 12.6641 4.316878e+08 84.6964 2.806695e+09 2.966904e+09 5.7561 1.910564e+08
2016-12-31 0.7493 -21.6300 -20.4000 -13.8400 78.570484 1.729370e+08 5.119535e+08 15.4300 5.810783e+08 81.1000 3.318619e+09 7.748695e+09 4.8600 3.314493e+08
2017-03-31 0.3262 -56.9138 -54.7474 -26.8197 64.234083 4.605382e+08 2.205816e+08 9.0828 2.629532e+08 92.6879 2.428574e+09 7.971078e+09 1.7487 3.314493e+08
2017-06-30 0.6684 107.1505 116.9275 36.8238 55.238250 8.443235e+08 4.569359e+08 13.7513 5.704178e+08 95.5545 3.322868e+09 7.326335e+09 3.6437 3.314493e+08
2017-09-30 0.6630 -0.9928 -5.6119 11.1736 50.384417 3.536411e+08 4.523996e+08 12.2464 5.384065e+08 99.5631 3.694151e+09 7.778353e+09 3.6427 3.314493e+08
2017-12-31 0.7449 12.5159 -28.2514 19.6033 45.485250 3.034728e+08 5.090213e+08 11.5207 3.862992e+08 60.2863 4.418326e+09 8.276772e+09 3.9406 3.409000e+08
2016-09-30 0.6600 -0.2500 -2.5200 13.5200 43.327667 3.466695e+07 5.455966e+07 13.8700 4.610903e+07 76.7200 3.934187e+08 4.382496e+08 5.7600 2.848906e+07
2016-12-31 0.3182 -47.2700 -35.0000 11.9500 63.220000 4.948543e+07 2.876988e+07 6.5300 2.997250e+07 86.4600 4.404252e+08 4.526373e+08 2.5300 4.591953e+07
2017-03-31 0.6949 142.0712 151.4006 2.7122 66.899417 -1.276328e+07 6.964360e+07 15.3953 7.535105e+07 95.2615 4.523703e+08 5.221263e+08 5.2954 4.591953e+07
2017-06-30 0.5425 58.7974 65.6053 7.5063 64.560333 1.466835e+08 1.105922e+08 22.7403 1.247853e+08 87.6914 4.863266e+08 5.790817e+08 7.8822 4.591953e+07
2017-09-30 0.8000 44.0255 45.6430 18.9271 64.561333 1.053011e+08 1.592810e+08 27.5394 1.817411e+08 75.2373 5.783742e+08 7.390937e+08 10.5010 4.591953e+07
2017-12-31 0.2860 -63.5692 -69.9259 -11.3657 109.730583 -4.151713e+07 5.802732e+07 11.3194 5.465697e+07 86.3494 5.126378e+08 7.675425e+08 3.4499 7.543034e+07
2016-03-31 0.0084 28.5500 29.3800 13.2200 3.478917 2.648065e+08 1.346673e+08 11.6400 2.324076e+08 85.6200 1.157333e+09 3.128069e+09 0.8100 7.860501e+08
2016-06-30 0.0220 172.4500 63.2700 -4.7400 3.649667 2.701510e+08 3.668949e+08 33.2800 3.794460e+08 66.4800 1.102519e+09 3.076703e+09 2.1300 7.860501e+08
2016-09-30 0.0043 -81.8300 -65.1100 12.1200 3.999250 3.306001e+08 6.664981e+07 5.3900 1.323896e+08 67.1700 1.236185e+09 3.148299e+09 0.4100 7.860501e+08
2016-12-31 0.0245 576.7100 -94.7700 179.3700 3.865833 2.049269e+09 4.510263e+08 13.0600 6.925479e+06 -1.2500 3.453534e+09 3.508789e+09 2.2700 8.400989e+08
2017-03-31 0.0354 121.4284 21460.4199 67.4380 4.363417 1.427245e+09 9.987004e+08 17.2710 1.493162e+09 98.0996 5.782531e+09 4.106009e+09 3.1374 8.400989e+08
2017-06-30 0.0141 -62.8770 -58.4281 1.5543 4.458667 2.054166e+09 3.707473e+08 6.3134 6.207354e+08 155.7238 5.872410e+09 3.752876e+09 1.2508 8.400989e+08
2017-09-30 0.0400 145.8937 114.6130 3.0512 7.000000 2.185045e+09 9.116443e+08 15.0645 1.332179e+09 100.5395 6.051591e+09 4.522277e+09 2.7485 8.400989e+08
2017-12-31 0.0520 44.1926 44.9506 6.4353 6.722417 2.762356e+09 1.314523e+09 20.4086 1.931002e+09 102.5679 6.441026e+09 5.517441e+09 2.9780 9.681907e+08

2256 rows × 14 columns

#数据去极值及标准化 去均值 不用写常数项
def winsorize_and_standarlize(data,qrange=[0.01,0.98],axis=0):
    '''
    input:
    data:Dataframe or series,输入数据
    qrange:list,list[0]下分位数,list[1],上分位数,极值用分位数代替
    '''
    if isinstance(data,pd.DataFrame):
        if axis == 0:
            q_down = data.quantile(qrange[0])
            q_up = data.quantile(qrange[1])
            
            index = data.index
            col = data.columns
            print('q_up上分位数',q_up)
            print('data.mean均值',data.mean(),'ok均值')
            print('price.mean()',data['mean_price'].mean())
            for n in col:
                
                
                #去掉极端值
                data[n][data[n] > q_up[n]] = q_up[n]
                data[n][data[n] < q_down[n]] = q_down[n]
                '''
                #标准化 未用
                data[n] = (data[n] - data[n].mean())/data[n].std()
                print(n,'data[n].mean()的值为',data[n].mean())
                #data[n] = data[n].fillna(0)
                '''
        else:
            data = data.stack()
            data = data.unstack(0)
            q = data.quantile(qrange)
            index = data.index
            col = data.columns
            for n in col:
                data[n][data[n] > q[n]] = q[n]
            data = (data - data.mean())/data.std()
            data = data.stack().unstack(0)
            data = data.fillna(0)
            
    elif isinstance(data,pd.Series):
        name = data.name
        q = data.quantile(qrange)
        data[data>q] = q
        data = (data - data.mean())/data.std()
        
    return data
data_pro = winsorize_and_standarlize(df)
data_pro
q_up上分位数 eps                            9.745900e-01
inc_net_profit_annual          8.806128e+02
inc_operation_profit_annual    8.235947e+02
inc_revenue_annual             1.868470e+02
mean_price                     6.516511e+01
net_operate_cash_flow          8.268597e+10
net_profit                     1.935970e+10
net_profit_margin              6.222397e+01
operating_profit               2.433390e+10
operating_profit_to_profit     1.604999e+02
operating_revenue              1.773546e+11
retained_profit                2.578779e+11
roe                            1.255319e+01
surplus_reserve_fund           1.246179e+11
Name: 0.98, dtype: float64
data.mean均值 eps                            2.329984e-01
inc_net_profit_annual          3.470843e+02
inc_operation_profit_annual    1.681235e+02
inc_revenue_annual             4.591364e+01
mean_price                     1.848996e+01
net_operate_cash_flow          3.960397e+09
net_profit                     2.305853e+09
net_profit_margin              1.932793e+01
operating_profit               2.851361e+09
operating_profit_to_profit     5.386575e+01
operating_revenue              2.064629e+10
retained_profit                3.035775e+10
roe                            3.589128e+00
surplus_reserve_fund           7.106409e+09
dtype: float64 ok均值
price.mean() 18.489957369723257
.dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; }
eps inc_net_profit_annual inc_operation_profit_annual inc_revenue_annual mean_price net_operate_cash_flow net_profit net_profit_margin operating_profit operating_profit_to_profit operating_revenue retained_profit roe surplus_reserve_fund
Unnamed: 0
2016-03-31 0.425300 47.540000 43.36000 10.08000 8.271833 5.926800e+10 6.086000e+09 22.1100 8.014000e+09 87.83000 2.753200e+10 5.901900e+10 3.49000 8.521000e+09
2016-06-30 0.361400 1.970000 1.60000 -1.07000 8.370500 -7.926415e+10 6.206000e+09 22.7900 8.142000e+09 86.81000 2.723700e+10 6.303600e+10 3.27000 8.521000e+09
2016-09-30 0.370000 3.560000 3.03000 -0.14000 8.921500 -7.926415e+10 6.427000e+09 23.6300 8.389000e+09 160.49987 2.719900e+10 6.946300e+10 3.30000 8.521000e+09
2016-12-31 0.226000 -39.630000 -37.61000 -5.34000 8.975500 8.268597e+10 3.880000e+09 15.0700 5.234000e+09 -380.68499 2.574700e+10 6.414300e+10 1.94000 1.078100e+10
2017-03-31 0.361900 60.154600 57.20290 7.63200 9.028333 -7.926415e+10 6.214000e+09 22.4235 8.228000e+09 92.30860 2.771200e+10 6.948300e+10 3.03190 1.078100e+10
2017-06-30 0.369200 2.027700 0.14580 -4.87510 8.753667 -1.317200e+10 6.340000e+09 24.0507 8.240000e+09 97.56160 2.636100e+10 7.311000e+10 3.02490 1.078100e+10
2017-09-30 0.380000 4.085200 3.54370 -2.27990 10.768917 -2.980700e+10 6.599000e+09 25.6172 8.532000e+09 98.04870 2.576000e+10 7.970900e+10 3.07240 1.078100e+10
2017-12-31 0.235100 -38.839200 -38.78340 0.74920 12.431917 3.920700e+10 4.036000e+09 15.5512 5.223000e+09 102.83630 2.595300e+10 7.966100e+10 1.83390 1.078100e+10
2016-03-31 0.075500 -92.380000 -92.07000 -72.64127 21.820000 -1.072613e+10 1.249823e+09 8.5500 1.646601e+09 74.77000 1.461131e+10 5.343109e+10 0.83000 2.806877e+10
2016-06-30 0.409300 367.650000 401.52000 186.84700 21.820000 3.652334e+10 5.844807e+09 9.7100 8.258004e+09 88.03000 6.018398e+10 5.000097e+10 4.56000 2.806877e+10
2016-09-30 0.260000 -28.220000 -28.76000 -29.78000 20.037500 1.718868e+10 4.195622e+09 9.9300 5.882695e+09 83.25000 4.225951e+10 5.291205e+10 2.94000 2.806877e+10
2016-12-31 0.974590 306.610000 295.00000 186.84700 23.069833 -3.419766e+09 1.706000e+10 13.8200 2.323648e+10 87.88000 1.234224e+11 6.120027e+10 11.93000 3.254077e+10
2017-03-31 0.063000 -93.498400 -93.29070 -72.64127 19.356917 -9.523936e+09 1.109171e+09 5.9667 1.559008e+09 82.67640 1.858923e+10 6.189568e+10 0.61160 3.254077e+10
2017-06-30 0.598500 706.351800 676.30410 175.54260 19.283500 3.137410e+10 8.943819e+09 17.4611 1.210265e+10 88.47160 5.122125e+10 5.978206e+10 5.83140 3.254077e+10
2017-09-30 0.343000 -46.739300 -41.94640 -7.67500 23.069000 -5.143923e+09 4.763538e+09 10.0730 7.026021e+09 72.91840 4.729003e+10 6.357034e+10 3.30830 3.254077e+10
2017-12-31 0.974590 370.067900 328.76670 166.01090 27.828917 6.561660e+10 1.935970e+10 17.8001 2.433390e+10 90.18650 1.257966e+11 7.717185e+10 12.55319 3.590007e+10
2016-03-31 0.228600 25.600000 344.30000 -30.97000 14.935583 3.945521e+09 1.061152e+09 4.8500 3.142410e+08 31.35000 2.185851e+10 1.462773e+10 3.18000 2.022709e+09
2016-06-30 0.196600 6.220000 -42.35000 18.48000 13.704167 -1.590590e+09 1.127202e+09 4.3500 1.811750e+08 -19.15000 2.589879e+10 1.544462e+10 2.68000 2.022709e+09
2016-09-30 0.260000 9.380000 152.21000 -8.08000 14.698833 -1.135629e+09 1.232917e+09 5.1800 4.569420e+08 -9.79000 2.380670e+10 1.549858e+10 3.49000 2.022709e+09
2016-12-31 -0.129495 -221.470985 -53.34000 24.63000 15.888917 4.040904e+09 -6.429817e+08 -16.2800 2.131900e+08 10.77000 2.966918e+10 1.028224e+10 -3.64750 2.022709e+09
2017-03-31 0.289900 127.281300 258.39300 -13.22780 15.712500 -9.711650e+08 1.317453e+09 5.1174 7.640580e+08 44.21630 2.574461e+10 1.149584e+10 4.49600 2.022709e+09
2017-06-30 0.257600 -6.959600 231.46210 9.79380 19.197167 -3.235387e+09 1.225763e+09 4.3365 2.532563e+09 75.08140 2.826598e+10 1.257511e+10 3.81530 2.022709e+09
2017-09-30 0.380000 42.837000 -21.42130 -20.15440 23.743083 1.036069e+09 1.750843e+09 7.7577 1.990054e+09 -37.83050 2.256914e+10 1.418689e+10 5.38560 2.022709e+09
2017-12-31 0.158300 -37.613900 -26.32080 42.83010 34.003917 1.039046e+10 1.092283e+09 3.3884 1.466255e+09 -0.65980 3.223553e+10 1.466768e+10 2.12280 2.205436e+09
2016-03-31 0.073200 -73.140000 -69.44000 -62.83000 6.492583 -1.397724e+09 6.400020e+08 11.6400 9.254854e+08 95.15000 5.500350e+09 2.238587e+10 1.57000 2.543815e+09
2016-06-30 0.119300 67.220000 48.59000 8.35000 6.177417 6.076731e+08 1.070220e+09 17.9600 1.375193e+09 77.34000 5.959879e+09 2.279104e+10 2.55000 2.543815e+09
2016-09-30 0.163000 33.540000 21.44000 27.34000 6.598250 1.097621e+10 1.429121e+09 18.8300 1.670046e+09 93.80000 7.589555e+09 2.412827e+10 3.42000 2.543815e+09
2016-12-31 0.484000 191.900000 175.46000 116.50000 6.704000 -5.782313e+09 4.171598e+09 25.3900 4.600311e+09 80.81000 1.643132e+10 2.783806e+10 9.52000 2.805448e+09
2017-03-31 0.092300 -80.527600 -75.44800 -62.53860 6.803750 -7.510819e+09 8.123113e+08 13.1967 1.129467e+09 93.12270 6.155396e+09 2.859505e+10 1.71430 2.805448e+09
2017-06-30 0.119000 21.938200 29.59160 24.01330 8.113583 -1.018259e+10 9.905180e+08 12.9759 1.463694e+09 96.46070 7.633513e+09 2.876039e+10 2.17700 2.805448e+09
... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2016-03-31 -0.065200 82.950000 88.22000 26.23000 13.292000 -9.905389e+07 -3.735655e+07 -3.5500 -3.394274e+07 140.06000 1.052482e+09 5.027835e+08 -1.47000 9.548766e+07
2016-06-30 0.006800 102.320000 37.11000 5.78000 20.172750 2.154776e+08 8.653756e+05 0.0800 -2.134785e+07 32.36000 1.113317e+09 5.064022e+08 0.15000 9.548766e+07
2016-09-30 0.080000 880.612820 333.87000 18.79000 25.900667 6.189952e+07 3.913605e+07 2.9600 4.992677e+07 57.81000 1.322482e+09 5.488654e+08 1.75000 9.548766e+07
2016-12-31 0.098000 41.710000 62.72000 5.95000 23.780000 7.941974e+08 5.546059e+07 3.9600 8.124189e+07 138.17000 1.401104e+09 6.000031e+08 1.71000 1.024114e+08
2017-03-31 0.424600 348.590400 316.14230 24.70000 32.809833 -1.637676e+08 2.487909e+08 14.2396 3.380819e+08 100.00010 1.747176e+09 8.516644e+08 5.62510 1.024114e+08
2017-06-30 0.714100 70.613700 48.37720 16.83430 34.699167 -4.569780e+08 4.244713e+08 20.7942 5.016365e+08 97.53420 2.041301e+09 1.274913e+09 8.83290 1.024114e+08
2017-09-30 0.710000 -0.474600 0.62610 15.48930 52.392000 -5.986665e+08 4.224566e+08 17.9198 5.047771e+08 104.40210 2.357484e+09 1.697863e+09 8.23450 1.024114e+08
2017-12-31 0.974590 86.981700 79.70830 48.77140 60.570167 -5.751204e+08 7.899165e+08 22.5223 9.071263e+08 100.57260 3.507261e+09 2.451631e+09 12.55319 1.462961e+08
2017-06-30 0.852500 551.125300 425.46950 67.45910 65.165108 8.018877e+08 3.585043e+08 14.7772 3.648609e+08 88.93700 2.426069e+09 2.147579e+09 6.80190 1.243390e+08
2017-09-30 0.974590 47.925000 77.34540 24.83820 65.165108 2.840959e+08 5.303175e+08 17.5100 6.470640e+08 97.78170 3.028661e+09 2.678022e+09 9.04540 1.243390e+08
2017-12-31 0.845500 -32.975300 -33.28520 -7.32880 65.165108 9.786372e+08 3.554438e+08 12.6641 4.316878e+08 84.69640 2.806695e+09 2.966904e+09 5.75610 1.910564e+08
2016-12-31 0.749300 -21.630000 -20.40000 -13.84000 65.165108 1.729370e+08 5.119535e+08 15.4300 5.810783e+08 81.10000 3.318619e+09 7.748695e+09 4.86000 3.314493e+08
2017-03-31 0.326200 -56.913800 -54.74740 -26.81970 64.234083 4.605382e+08 2.205816e+08 9.0828 2.629532e+08 92.68790 2.428574e+09 7.971078e+09 1.74870 3.314493e+08
2017-06-30 0.668400 107.150500 116.92750 36.82380 55.238250 8.443235e+08 4.569359e+08 13.7513 5.704178e+08 95.55450 3.322868e+09 7.326335e+09 3.64370 3.314493e+08
2017-09-30 0.663000 -0.992800 -5.61190 11.17360 50.384417 3.536411e+08 4.523996e+08 12.2464 5.384065e+08 99.56310 3.694151e+09 7.778353e+09 3.64270 3.314493e+08
2017-12-31 0.744900 12.515900 -28.25140 19.60330 45.485250 3.034728e+08 5.090213e+08 11.5207 3.862992e+08 60.28630 4.418326e+09 8.276772e+09 3.94060 3.409000e+08
2016-09-30 0.660000 -0.250000 -2.52000 13.52000 43.327667 3.466695e+07 5.455966e+07 13.8700 4.610903e+07 76.72000 3.934187e+08 4.382496e+08 5.76000 2.848906e+07
2016-12-31 0.318200 -47.270000 -35.00000 11.95000 63.220000 4.948543e+07 2.876988e+07 6.5300 2.997250e+07 86.46000 4.404252e+08 4.526373e+08 2.53000 4.591953e+07
2017-03-31 0.694900 142.071200 151.40060 2.71220 65.165108 -1.276328e+07 6.964360e+07 15.3953 7.535105e+07 95.26150 4.523703e+08 5.221263e+08 5.29540 4.591953e+07
2017-06-30 0.542500 58.797400 65.60530 7.50630 64.560333 1.466835e+08 1.105922e+08 22.7403 1.247853e+08 87.69140 4.863266e+08 5.790817e+08 7.88220 4.591953e+07
2017-09-30 0.800000 44.025500 45.64300 18.92710 64.561333 1.053011e+08 1.592810e+08 27.5394 1.817411e+08 75.23730 5.783742e+08 7.390937e+08 10.50100 4.591953e+07
2017-12-31 0.286000 -63.569200 -69.92590 -11.36570 65.165108 -4.151713e+07 5.802732e+07 11.3194 5.465697e+07 86.34940 5.126378e+08 7.675425e+08 3.44990 7.543034e+07
2016-03-31 0.008400 28.550000 29.38000 13.22000 3.478917 2.648065e+08 1.346673e+08 11.6400 2.324076e+08 85.62000 1.157333e+09 3.128069e+09 0.81000 7.860501e+08
2016-06-30 0.022000 172.450000 63.27000 -4.74000 3.649667 2.701510e+08 3.668949e+08 33.2800 3.794460e+08 66.48000 1.102519e+09 3.076703e+09 2.13000 7.860501e+08
2016-09-30 0.004300 -81.830000 -65.11000 12.12000 3.999250 3.306001e+08 6.664981e+07 5.3900 1.323896e+08 67.17000 1.236185e+09 3.148299e+09 0.41000 7.860501e+08
2016-12-31 0.024500 576.710000 -94.77000 179.37000 3.865833 2.049269e+09 4.510263e+08 13.0600 6.925479e+06 -1.25000 3.453534e+09 3.508789e+09 2.27000 8.400989e+08
2017-03-31 0.035400 121.428400 823.59474 67.43800 4.363417 1.427245e+09 9.987004e+08 17.2710 1.493162e+09 98.09960 5.782531e+09 4.106009e+09 3.13740 8.400989e+08
2017-06-30 0.014100 -62.877000 -58.42810 1.55430 4.458667 2.054166e+09 3.707473e+08 6.3134 6.207354e+08 155.72380 5.872410e+09 3.752876e+09 1.25080 8.400989e+08
2017-09-30 0.040000 145.893700 114.61300 3.05120 7.000000 2.185045e+09 9.116443e+08 15.0645 1.332179e+09 100.53950 6.051591e+09 4.522277e+09 2.74850 8.400989e+08
2017-12-31 0.052000 44.192600 44.95060 6.43530 6.722417 2.762356e+09 1.314523e+09 20.4086 1.931002e+09 102.56790 6.441026e+09 5.517441e+09 2.97800 9.681907e+08

2256 rows × 14 columns

price = data_pro['mean_price']
data_pro.drop(labels=['mean_price'], axis=1,inplace = True)
#df.insert(0, 'close', close)
data_pro.insert( 0, 'price', price)
#close
data_pro
.dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; }
price eps inc_net_profit_annual inc_operation_profit_annual inc_revenue_annual net_operate_cash_flow net_profit net_profit_margin operating_profit operating_profit_to_profit operating_revenue retained_profit roe surplus_reserve_fund
Unnamed: 0
2016-03-31 8.271833 0.425300 47.540000 43.36000 10.08000 5.926800e+10 6.086000e+09 22.1100 8.014000e+09 87.83000 2.753200e+10 5.901900e+10 3.49000 8.521000e+09
2016-06-30 8.370500 0.361400 1.970000 1.60000 -1.07000 -7.926415e+10 6.206000e+09 22.7900 8.142000e+09 86.81000 2.723700e+10 6.303600e+10 3.27000 8.521000e+09
2016-09-30 8.921500 0.370000 3.560000 3.03000 -0.14000 -7.926415e+10 6.427000e+09 23.6300 8.389000e+09 160.49987 2.719900e+10 6.946300e+10 3.30000 8.521000e+09
2016-12-31 8.975500 0.226000 -39.630000 -37.61000 -5.34000 8.268597e+10 3.880000e+09 15.0700 5.234000e+09 -380.68499 2.574700e+10 6.414300e+10 1.94000 1.078100e+10
2017-03-31 9.028333 0.361900 60.154600 57.20290 7.63200 -7.926415e+10 6.214000e+09 22.4235 8.228000e+09 92.30860 2.771200e+10 6.948300e+10 3.03190 1.078100e+10
2017-06-30 8.753667 0.369200 2.027700 0.14580 -4.87510 -1.317200e+10 6.340000e+09 24.0507 8.240000e+09 97.56160 2.636100e+10 7.311000e+10 3.02490 1.078100e+10
2017-09-30 10.768917 0.380000 4.085200 3.54370 -2.27990 -2.980700e+10 6.599000e+09 25.6172 8.532000e+09 98.04870 2.576000e+10 7.970900e+10 3.07240 1.078100e+10
2017-12-31 12.431917 0.235100 -38.839200 -38.78340 0.74920 3.920700e+10 4.036000e+09 15.5512 5.223000e+09 102.83630 2.595300e+10 7.966100e+10 1.83390 1.078100e+10
2016-03-31 21.820000 0.075500 -92.380000 -92.07000 -72.64127 -1.072613e+10 1.249823e+09 8.5500 1.646601e+09 74.77000 1.461131e+10 5.343109e+10 0.83000 2.806877e+10
2016-06-30 21.820000 0.409300 367.650000 401.52000 186.84700 3.652334e+10 5.844807e+09 9.7100 8.258004e+09 88.03000 6.018398e+10 5.000097e+10 4.56000 2.806877e+10
2016-09-30 20.037500 0.260000 -28.220000 -28.76000 -29.78000 1.718868e+10 4.195622e+09 9.9300 5.882695e+09 83.25000 4.225951e+10 5.291205e+10 2.94000 2.806877e+10
2016-12-31 23.069833 0.974590 306.610000 295.00000 186.84700 -3.419766e+09 1.706000e+10 13.8200 2.323648e+10 87.88000 1.234224e+11 6.120027e+10 11.93000 3.254077e+10
2017-03-31 19.356917 0.063000 -93.498400 -93.29070 -72.64127 -9.523936e+09 1.109171e+09 5.9667 1.559008e+09 82.67640 1.858923e+10 6.189568e+10 0.61160 3.254077e+10
2017-06-30 19.283500 0.598500 706.351800 676.30410 175.54260 3.137410e+10 8.943819e+09 17.4611 1.210265e+10 88.47160 5.122125e+10 5.978206e+10 5.83140 3.254077e+10
2017-09-30 23.069000 0.343000 -46.739300 -41.94640 -7.67500 -5.143923e+09 4.763538e+09 10.0730 7.026021e+09 72.91840 4.729003e+10 6.357034e+10 3.30830 3.254077e+10
2017-12-31 27.828917 0.974590 370.067900 328.76670 166.01090 6.561660e+10 1.935970e+10 17.8001 2.433390e+10 90.18650 1.257966e+11 7.717185e+10 12.55319 3.590007e+10
2016-03-31 14.935583 0.228600 25.600000 344.30000 -30.97000 3.945521e+09 1.061152e+09 4.8500 3.142410e+08 31.35000 2.185851e+10 1.462773e+10 3.18000 2.022709e+09
2016-06-30 13.704167 0.196600 6.220000 -42.35000 18.48000 -1.590590e+09 1.127202e+09 4.3500 1.811750e+08 -19.15000 2.589879e+10 1.544462e+10 2.68000 2.022709e+09
2016-09-30 14.698833 0.260000 9.380000 152.21000 -8.08000 -1.135629e+09 1.232917e+09 5.1800 4.569420e+08 -9.79000 2.380670e+10 1.549858e+10 3.49000 2.022709e+09
2016-12-31 15.888917 -0.129495 -221.470985 -53.34000 24.63000 4.040904e+09 -6.429817e+08 -16.2800 2.131900e+08 10.77000 2.966918e+10 1.028224e+10 -3.64750 2.022709e+09
2017-03-31 15.712500 0.289900 127.281300 258.39300 -13.22780 -9.711650e+08 1.317453e+09 5.1174 7.640580e+08 44.21630 2.574461e+10 1.149584e+10 4.49600 2.022709e+09
2017-06-30 19.197167 0.257600 -6.959600 231.46210 9.79380 -3.235387e+09 1.225763e+09 4.3365 2.532563e+09 75.08140 2.826598e+10 1.257511e+10 3.81530 2.022709e+09
2017-09-30 23.743083 0.380000 42.837000 -21.42130 -20.15440 1.036069e+09 1.750843e+09 7.7577 1.990054e+09 -37.83050 2.256914e+10 1.418689e+10 5.38560 2.022709e+09
2017-12-31 34.003917 0.158300 -37.613900 -26.32080 42.83010 1.039046e+10 1.092283e+09 3.3884 1.466255e+09 -0.65980 3.223553e+10 1.466768e+10 2.12280 2.205436e+09
2016-03-31 6.492583 0.073200 -73.140000 -69.44000 -62.83000 -1.397724e+09 6.400020e+08 11.6400 9.254854e+08 95.15000 5.500350e+09 2.238587e+10 1.57000 2.543815e+09
2016-06-30 6.177417 0.119300 67.220000 48.59000 8.35000 6.076731e+08 1.070220e+09 17.9600 1.375193e+09 77.34000 5.959879e+09 2.279104e+10 2.55000 2.543815e+09
2016-09-30 6.598250 0.163000 33.540000 21.44000 27.34000 1.097621e+10 1.429121e+09 18.8300 1.670046e+09 93.80000 7.589555e+09 2.412827e+10 3.42000 2.543815e+09
2016-12-31 6.704000 0.484000 191.900000 175.46000 116.50000 -5.782313e+09 4.171598e+09 25.3900 4.600311e+09 80.81000 1.643132e+10 2.783806e+10 9.52000 2.805448e+09
2017-03-31 6.803750 0.092300 -80.527600 -75.44800 -62.53860 -7.510819e+09 8.123113e+08 13.1967 1.129467e+09 93.12270 6.155396e+09 2.859505e+10 1.71430 2.805448e+09
2017-06-30 8.113583 0.119000 21.938200 29.59160 24.01330 -1.018259e+10 9.905180e+08 12.9759 1.463694e+09 96.46070 7.633513e+09 2.876039e+10 2.17700 2.805448e+09
... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2016-03-31 13.292000 -0.065200 82.950000 88.22000 26.23000 -9.905389e+07 -3.735655e+07 -3.5500 -3.394274e+07 140.06000 1.052482e+09 5.027835e+08 -1.47000 9.548766e+07
2016-06-30 20.172750 0.006800 102.320000 37.11000 5.78000 2.154776e+08 8.653756e+05 0.0800 -2.134785e+07 32.36000 1.113317e+09 5.064022e+08 0.15000 9.548766e+07
2016-09-30 25.900667 0.080000 880.612820 333.87000 18.79000 6.189952e+07 3.913605e+07 2.9600 4.992677e+07 57.81000 1.322482e+09 5.488654e+08 1.75000 9.548766e+07
2016-12-31 23.780000 0.098000 41.710000 62.72000 5.95000 7.941974e+08 5.546059e+07 3.9600 8.124189e+07 138.17000 1.401104e+09 6.000031e+08 1.71000 1.024114e+08
2017-03-31 32.809833 0.424600 348.590400 316.14230 24.70000 -1.637676e+08 2.487909e+08 14.2396 3.380819e+08 100.00010 1.747176e+09 8.516644e+08 5.62510 1.024114e+08
2017-06-30 34.699167 0.714100 70.613700 48.37720 16.83430 -4.569780e+08 4.244713e+08 20.7942 5.016365e+08 97.53420 2.041301e+09 1.274913e+09 8.83290 1.024114e+08
2017-09-30 52.392000 0.710000 -0.474600 0.62610 15.48930 -5.986665e+08 4.224566e+08 17.9198 5.047771e+08 104.40210 2.357484e+09 1.697863e+09 8.23450 1.024114e+08
2017-12-31 60.570167 0.974590 86.981700 79.70830 48.77140 -5.751204e+08 7.899165e+08 22.5223 9.071263e+08 100.57260 3.507261e+09 2.451631e+09 12.55319 1.462961e+08
2017-06-30 65.165108 0.852500 551.125300 425.46950 67.45910 8.018877e+08 3.585043e+08 14.7772 3.648609e+08 88.93700 2.426069e+09 2.147579e+09 6.80190 1.243390e+08
2017-09-30 65.165108 0.974590 47.925000 77.34540 24.83820 2.840959e+08 5.303175e+08 17.5100 6.470640e+08 97.78170 3.028661e+09 2.678022e+09 9.04540 1.243390e+08
2017-12-31 65.165108 0.845500 -32.975300 -33.28520 -7.32880 9.786372e+08 3.554438e+08 12.6641 4.316878e+08 84.69640 2.806695e+09 2.966904e+09 5.75610 1.910564e+08
2016-12-31 65.165108 0.749300 -21.630000 -20.40000 -13.84000 1.729370e+08 5.119535e+08 15.4300 5.810783e+08 81.10000 3.318619e+09 7.748695e+09 4.86000 3.314493e+08
2017-03-31 64.234083 0.326200 -56.913800 -54.74740 -26.81970 4.605382e+08 2.205816e+08 9.0828 2.629532e+08 92.68790 2.428574e+09 7.971078e+09 1.74870 3.314493e+08
2017-06-30 55.238250 0.668400 107.150500 116.92750 36.82380 8.443235e+08 4.569359e+08 13.7513 5.704178e+08 95.55450 3.322868e+09 7.326335e+09 3.64370 3.314493e+08
2017-09-30 50.384417 0.663000 -0.992800 -5.61190 11.17360 3.536411e+08 4.523996e+08 12.2464 5.384065e+08 99.56310 3.694151e+09 7.778353e+09 3.64270 3.314493e+08
2017-12-31 45.485250 0.744900 12.515900 -28.25140 19.60330 3.034728e+08 5.090213e+08 11.5207 3.862992e+08 60.28630 4.418326e+09 8.276772e+09 3.94060 3.409000e+08
2016-09-30 43.327667 0.660000 -0.250000 -2.52000 13.52000 3.466695e+07 5.455966e+07 13.8700 4.610903e+07 76.72000 3.934187e+08 4.382496e+08 5.76000 2.848906e+07
2016-12-31 63.220000 0.318200 -47.270000 -35.00000 11.95000 4.948543e+07 2.876988e+07 6.5300 2.997250e+07 86.46000 4.404252e+08 4.526373e+08 2.53000 4.591953e+07
2017-03-31 65.165108 0.694900 142.071200 151.40060 2.71220 -1.276328e+07 6.964360e+07 15.3953 7.535105e+07 95.26150 4.523703e+08 5.221263e+08 5.29540 4.591953e+07
2017-06-30 64.560333 0.542500 58.797400 65.60530 7.50630 1.466835e+08 1.105922e+08 22.7403 1.247853e+08 87.69140 4.863266e+08 5.790817e+08 7.88220 4.591953e+07
2017-09-30 64.561333 0.800000 44.025500 45.64300 18.92710 1.053011e+08 1.592810e+08 27.5394 1.817411e+08 75.23730 5.783742e+08 7.390937e+08 10.50100 4.591953e+07
2017-12-31 65.165108 0.286000 -63.569200 -69.92590 -11.36570 -4.151713e+07 5.802732e+07 11.3194 5.465697e+07 86.34940 5.126378e+08 7.675425e+08 3.44990 7.543034e+07
2016-03-31 3.478917 0.008400 28.550000 29.38000 13.22000 2.648065e+08 1.346673e+08 11.6400 2.324076e+08 85.62000 1.157333e+09 3.128069e+09 0.81000 7.860501e+08
2016-06-30 3.649667 0.022000 172.450000 63.27000 -4.74000 2.701510e+08 3.668949e+08 33.2800 3.794460e+08 66.48000 1.102519e+09 3.076703e+09 2.13000 7.860501e+08
2016-09-30 3.999250 0.004300 -81.830000 -65.11000 12.12000 3.306001e+08 6.664981e+07 5.3900 1.323896e+08 67.17000 1.236185e+09 3.148299e+09 0.41000 7.860501e+08
2016-12-31 3.865833 0.024500 576.710000 -94.77000 179.37000 2.049269e+09 4.510263e+08 13.0600 6.925479e+06 -1.25000 3.453534e+09 3.508789e+09 2.27000 8.400989e+08
2017-03-31 4.363417 0.035400 121.428400 823.59474 67.43800 1.427245e+09 9.987004e+08 17.2710 1.493162e+09 98.09960 5.782531e+09 4.106009e+09 3.13740 8.400989e+08
2017-06-30 4.458667 0.014100 -62.877000 -58.42810 1.55430 2.054166e+09 3.707473e+08 6.3134 6.207354e+08 155.72380 5.872410e+09 3.752876e+09 1.25080 8.400989e+08
2017-09-30 7.000000 0.040000 145.893700 114.61300 3.05120 2.185045e+09 9.116443e+08 15.0645 1.332179e+09 100.53950 6.051591e+09 4.522277e+09 2.74850 8.400989e+08
2017-12-31 6.722417 0.052000 44.192600 44.95060 6.43530 2.762356e+09 1.314523e+09 20.4086 1.931002e+09 102.56790 6.441026e+09 5.517441e+09 2.97800 9.681907e+08

2256 rows × 14 columns

df=data_pro
X= df.values[:, 1:]
Y =df.values[:, 0]
X.shape  #划分 x和标签y 
(2256, 13)
import numpy as np
import matplotlib.pyplot as plt

sampleRatio=0.2               #划分训练集和测试集各一半
m=len(X)
sampleBoundary=int(m*sampleRatio)
myshuffle=list(range(m))      #注意Python3中range()返回range对象而不是数组对象,要将其转为序列
np.random.shuffle(myshuffle)  #shuffle()函数将序列内的元素全部随机排序
#分别取出训练集和测试集的数据
train_fea= X[myshuffle[sampleBoundary:]]    #前一半数据集作为训练集
train_tar= Y[myshuffle[sampleBoundary:]]

test_fea=  X[myshuffle[:sampleBoundary]]     #后一半数据作为测试集
test_tar=  Y[myshuffle[:sampleBoundary]]
train_fea.shape
(1805, 13)
from sklearn.preprocessing import StandardScaler
ss_x = StandardScaler()
ss_y = StandardScaler()
X=train_fea
y=train_tar
Xt=test_fea
yt=test_tar
X
array([[ 1.59000000e-01, -3.69370000e+00, -6.24900000e+00, ...,
         5.43710403e+09,  2.84870000e+00,  3.91315683e+08],
       [ 1.46000000e-01,  8.80612820e+02,  1.86533700e+02, ...,
         1.33470467e+10,  4.15210000e+00,  9.10232816e+08],
       [ 1.12600000e-01, -6.52300000e+01, -1.43286600e+02, ...,
         1.33002496e+10,  2.15000000e+00,  1.36442470e+09],
       ...,
       [ 1.17300000e-01, -4.63040000e+00, -2.03390000e+00, ...,
         7.83867392e+08,  4.87600000e+00,  3.88474752e+08],
       [ 5.01000000e-02,  8.93000000e+00,  7.55000000e+00, ...,
         6.22280909e+09,  1.28000000e+00,  2.70854323e+09],
       [ 6.00000000e-02, -6.03700000e+01, -5.79800000e+01, ...,
         7.80361165e+09,  1.46000000e+00,  9.09954112e+08]])
X= ss_x.fit_transform(X)

Xt = ss_x.transform(Xt)

X
array([[-0.28493819, -0.31704479, -0.3499504 , ..., -0.35944818,
        -0.22173938, -0.27304024],
       [-0.34466505,  4.87134214,  0.81888137, ..., -0.18737853,
         0.23614074, -0.24715465],
       [-0.49811715, -0.67808943, -1.18080245, ..., -0.18839654,
        -0.46719038, -0.2244978 ],
       ...,
       [-0.47652359, -0.32254058, -0.32439446, ..., -0.46067278,
         0.49044441, -0.27318196],
       [-0.78526553, -0.24297925, -0.26628776, ..., -0.34235627,
        -0.7728185 , -0.15744796],
       [-0.73978122, -0.64957493, -0.66359284, ..., -0.30796814,
        -0.7095851 , -0.24716855]])
# 导入库
import numpy as np  # numpy库
from sklearn.linear_model import BayesianRidge, LinearRegression, ElasticNet  # 批量导入要实现的回归算法
from sklearn.svm import SVR  # SVM中的回归算法
from sklearn.ensemble.gradient_boosting import GradientBoostingRegressor  # 集成算法
from sklearn.model_selection import cross_val_score  # 交叉检验
from sklearn.metrics import explained_variance_score, mean_absolute_error, mean_squared_error, r2_score  # 批量导入指标算法
import pandas as pd  # 导入pandas
import matplotlib.pyplot as plt  # 导入图形展示库

from sklearn.neural_network import MLPRegressor  # 多层线性回归
# 训练回归模型
n_folds = 8  # 设置交叉检验的次数
model_br = BayesianRidge()     # 建立贝叶斯岭回归模型对象

model_lr = LinearRegression()  # 建立普通线性回归模型对象
model_etc = ElasticNet()       # 建立弹性网络回归模型对象

model_svr = SVR()              # 建立支持向量机回归模型对象

model_gbr = GradientBoostingRegressor()  # 建立梯度增强回归模型对象  ,未用

model_mlp = MLPRegressor(solver='lbfgs', alpha=1e-5,hidden_layer_sizes=(8, 4,2), random_state=1)

      
model_names = ['BayesianRidge', 'LinearRegression', 'SVR', 'mlp']  # 不同模型的名称列表 , 'ElasticNet' 'GBR',
model_dic = [model_br, model_lr, model_svr, model_mlp]  # 不同回归模型对象的集合  , model_gbr  , model_etc
cv_score_list = []  # 交叉检验结果列表


pre_y_list = []  # 各个回归模型  预测的y值列表

for model in model_dic:  # 读出每个回归模型对象
    scores = cross_val_score(model, X, y, cv=n_folds)  # 将每个回归模型 导入交叉检验模型中  做训练检验
    cv_score_list.append(scores)                     # 将交叉检验结果存入结果列表
    
    pre_y_list.append(model.fit(X, y).predict(Xt))  # 将回归训练中 得到的预测y 存入列表  测试集合
    
# 模型效果指标评估
n_samples, n_features = X.shape  # 总样本量,总特征数
model_metrics_name = [explained_variance_score, mean_absolute_error, mean_squared_error, r2_score]  # 回归评估指标对象集
model_metrics_list = []  # 回归评估指标列表

for i in range(len(model_names)):  # 循环 每个模型索引
    
    tmp_list = []  # 每个内循环的临时结果列表
    for m in model_metrics_name:  # 循环每个指标对象
        
        tmp_score = m(yt, pre_y_list[i])  # 计算每个回归指标结果            # 测试集合
        
        tmp_list.append(tmp_score)  # 将结果存入每个内循环的临时结果列表
        
    model_metrics_list.append(tmp_list)  # 将结果存入回归评估指标列表
    
df1 = pd.DataFrame(cv_score_list, index=model_names)  # 建立交叉检验的数据框
df2 = pd.DataFrame(model_metrics_list, index=model_names, columns=['ev', 'mae', 'mse', 'r2'])  # 建立回归指标的数据框
print('ok')
ok
print('ok')
print ('samples: %d \t features: %d' % (n_samples, n_features))  # 打印输出样本量和特征数量


print (70 * '-')  # 打印分隔线
print ('cross validation result:')  # 打印输出 标题
print (df1)  # 打印输出 交叉检验的数据框


print (70 * '-')  # 打印分隔线
print ('regression metrics:')  # 打印输出 标题
print (df2)  # 打印输出回归指标的数据框


print (70 * '-')  # 打印分隔线
print ('short name \t full name')  # 打印输出 缩写和全名标题
print ('ev \t explained_variance')
print ('mae \t mean_absolute_error')
print ('mse \t mean_squared_error')
print ('r2 \t r2')
print (70 * '-')  # 打印分隔线
ok
samples: 1805 	 features: 13
----------------------------------------------------------------------
cross validation result:
                         0         1         2         3         4         5  \
BayesianRidge     0.396419  0.322424  0.433829  0.517023  0.306590  0.472300   
LinearRegression  0.395534  0.318223  0.438346  0.521255  0.313822  0.472499   
SVR               0.344441  0.317279  0.416976  0.417177  0.274501  0.348430   
mlp               0.539338  0.536839  0.552823  0.668490  0.400322  0.604423   

                         6         7  
BayesianRidge     0.246520  0.332698  
LinearRegression  0.248438  0.332534  
SVR               0.310007  0.227168  
mlp               0.483398  0.481540  
----------------------------------------------------------------------
regression metrics:
                        ev       mae         mse        r2
BayesianRidge     0.393803  7.583999  107.046468  0.393748
LinearRegression  0.398220  7.514669  106.274107  0.398122
SVR               0.374950  7.084663  118.931724  0.326436
mlp               0.571992  6.051157   75.583389  0.571937
----------------------------------------------------------------------
short name 	 full name
ev 	 explained_variance
mae 	 mean_absolute_error
mse 	 mean_squared_error
r2 	 r2
----------------------------------------------------------------------
# 模型效果可视化
plt.figure()  # 创建画布
plt.plot(np.arange(Xt.shape[0]), yt, color='k', label='true y')  # 画出原始值的曲线
color_list = ['r', 'b', 'y', 'c','<', 'g']  # 颜色列表
linestyle_list = ['-', '.', 'o', 'v', '*','m']  # 样式列表
#print(pre_y_list.shape())
for i, pre_y in enumerate(pre_y_list):  # 读出通过回归模型 预测得到的索引及结果
    #print(i)
    #print(len(pre_y))
   
    plt.plot(np.arange(Xt.shape[0]), pre_y_list[i], color_list[i], label=model_names[i])  # 画出每条预测结果线
    
    
plt.title('regression result comparison')  # 标题
plt.legend(loc='upper right')            # 图例位置
plt.ylabel('real and predicted value')  # y轴标题
plt.show()  # 展示图像
 
from sklearn import linear_model
#使用最小二乘线性回归进行拟合,导入相应的模块
lr=linear_model.LinearRegression()

lr.fit(train_fea,train_tar)  #拟合
y_pred=lr.predict(test_fea)       #得到预测值集合y
plt.scatter(y_pred,test_tar)      #画出散点图,横轴是预测值,纵轴是真实值
plt.plot([y_pred.min(), y_pred.max()], [y_pred.min(), y_pred.max()], 'b',lw=5) #直线的起点为(y.min(),y.min()),终点是(y.max(),y.max())
plt.show()
coef=lr.coef_                #获得该回该方程的回归系数与截距
intercept=lr.intercept_
print("预测方程回归系数:",coef)
print("预测方程截距:",intercept)


score=lr.score(test_fea,test_tar)    #对得到的模型打分
print("对该模型的评分是:%.5f" %score)
#--------------------- 
预测方程回归系数: [ 4.94600385e+01 -4.60689931e-03 -4.91319668e-03 -1.43372238e-02
  2.24022698e-11 -4.31800044e-09 -1.30375890e-02  1.90868281e-09
 -3.93320621e-03 -3.00157607e-11  1.31595091e-11 -5.89393971e-01
  1.45230980e-10]
预测方程截距: 12.127608740032237
对该模型的评分是:0.39812
train_fea1= ss_x.fit_transform(train_fea)

test_fea1 = ss_x.transform(test_fea)

test_fea1 
array([[-0.83626308, -0.18383806, -0.48382639, ..., -0.02133176,
        -0.89225938, -0.22886553],
       [-0.55462795,  4.87134214,  1.53034606, ..., -0.33164304,
        -0.76579257, -0.27966881],
       [ 0.82230595, -0.23399014, -0.28125294, ..., -0.42781367,
         0.95306703, -0.27456991],
       ...,
       [ 0.13314985, -0.35535514, -0.37431921, ..., -0.42063523,
         0.92594693, -0.28566841],
       [-0.21602258, -0.51809139, -0.55173142, ..., -0.1192583 ,
        -0.68148136, -0.16249456],
       [-0.29596469,  4.87134214,  4.68135027, ..., -0.44479642,
        -0.15102335, -0.28701121]])
from sklearn import linear_model
#使用最小二乘线性回归进行拟合,导入相应的模块
lr=linear_model.LinearRegression()

lr.fit(train_fea1,train_tar)  #拟合
y_pred=lr.predict(test_fea1)       #得到预测值集合y
plt.scatter(y_pred,test_tar)      #画出散点图,横轴是预测值,纵轴是真实值
plt.plot([y_pred.min(), y_pred.max()], [y_pred.min(), y_pred.max()], 'b',lw=5) #直线的起点为(y.min(),y.min()),终点是(y.max(),y.max())
plt.show()
coef=lr.coef_                #获得该回该方程的回归系数与截距
intercept=lr.intercept_
print("预测方程回归系数:",coef)
print("预测方程截距:",intercept)


score=lr.score(test_fea1,test_tar)    #对得到的模型打分
print("对该模型的评分是:%.5f" %score)
#--------------------- 
预测方程回归系数: [ 10.76534865  -0.78519801  -0.81036411  -0.6334516    0.36665001
 -15.76471913  -0.20603864   8.75917736  -0.25310459  -1.0281977
   0.60493502  -1.67776691   2.91138111]
预测方程截距: 17.05397318789621
对该模型的评分是:0.39812
df
.dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; }
price eps inc_net_profit_annual inc_operation_profit_annual inc_revenue_annual net_operate_cash_flow net_profit net_profit_margin operating_profit operating_profit_to_profit operating_revenue retained_profit roe surplus_reserve_fund
Unnamed: 0
2016-03-31 8.271833 0.42530 47.54000 43.36000 10.0800 5.926800e+10 6.086000e+09 22.11000 8.014000e+09 87.83000 2.753200e+10 5.901900e+10 3.49000 8.521000e+09
2016-06-30 8.370500 0.36140 1.97000 1.60000 -1.0700 -3.381803e+10 6.206000e+09 22.79000 8.142000e+09 86.81000 2.723700e+10 6.303600e+10 3.27000 8.521000e+09
2016-09-30 8.921500 0.37000 3.56000 3.03000 -0.1400 -3.381803e+10 6.427000e+09 23.63000 8.389000e+09 160.49987 2.719900e+10 6.946300e+10 3.30000 8.521000e+09
2016-12-31 8.975500 0.22600 -39.63000 -37.61000 -5.3400 8.268597e+10 3.880000e+09 15.07000 5.234000e+09 -228.93400 2.574700e+10 6.414300e+10 1.94000 1.078100e+10
2017-03-31 9.028333 0.36190 60.15460 57.20290 7.6320 -3.381803e+10 6.214000e+09 22.42350 8.228000e+09 92.30860 2.771200e+10 6.948300e+10 3.03190 1.078100e+10
2017-06-30 8.753667 0.36920 2.02770 0.14580 -4.8751 -1.317200e+10 6.340000e+09 24.05070 8.240000e+09 97.56160 2.636100e+10 7.311000e+10 3.02490 1.078100e+10
2017-09-30 10.768917 0.38000 4.08520 3.54370 -2.2799 -2.980700e+10 6.599000e+09 25.61720 8.532000e+09 98.04870 2.576000e+10 7.970900e+10 3.07240 1.078100e+10
2017-12-31 12.431917 0.23510 -38.83920 -38.78340 0.7492 3.920700e+10 4.036000e+09 15.55120 5.223000e+09 102.83630 2.595300e+10 7.966100e+10 1.83390 1.078100e+10
2016-03-31 21.820000 0.07550 -92.38000 -92.07000 -63.6409 -1.072613e+10 1.249823e+09 8.55000 1.646601e+09 74.77000 1.461131e+10 5.343109e+10 0.83000 2.806877e+10
2016-06-30 21.820000 0.40930 367.65000 401.52000 186.8470 3.652334e+10 5.844807e+09 9.71000 8.258004e+09 88.03000 6.018398e+10 5.000097e+10 4.56000 2.806877e+10
2016-09-30 20.037500 0.26000 -28.22000 -28.76000 -29.7800 1.718868e+10 4.195622e+09 9.93000 5.882695e+09 83.25000 4.225951e+10 5.291205e+10 2.94000 2.806877e+10
2016-12-31 23.069833 0.97459 306.61000 295.00000 186.8470 -3.419766e+09 1.706000e+10 13.82000 2.323648e+10 87.88000 1.234224e+11 6.120027e+10 11.93000 3.254077e+10
2017-03-31 19.356917 0.06300 -93.49840 -93.29070 -63.6409 -9.523936e+09 1.109171e+09 5.96670 1.559008e+09 82.67640 1.858923e+10 6.189568e+10 0.61160 3.254077e+10
2017-06-30 19.283500 0.59850 706.35180 676.30410 175.5426 3.137410e+10 8.943819e+09 17.46110 1.210265e+10 88.47160 5.122125e+10 5.978206e+10 5.83140 3.254077e+10
2017-09-30 23.069000 0.34300 -46.73930 -41.94640 -7.6750 -5.143923e+09 4.763538e+09 10.07300 7.026021e+09 72.91840 4.729003e+10 6.357034e+10 3.30830 3.254077e+10
2017-12-31 27.828917 0.97459 370.06790 328.76670 166.0109 6.561660e+10 1.935970e+10 17.80010 2.433390e+10 90.18650 1.257966e+11 7.717185e+10 12.55319 3.590007e+10
2016-03-31 14.935583 0.22860 25.60000 344.30000 -30.9700 3.945521e+09 1.061152e+09 4.85000 3.142410e+08 31.35000 2.185851e+10 1.462773e+10 3.18000 2.022709e+09
2016-06-30 13.704167 0.19660 6.22000 -42.35000 18.4800 -1.590590e+09 1.127202e+09 4.35000 1.811750e+08 -19.15000 2.589879e+10 1.544462e+10 2.68000 2.022709e+09
2016-09-30 14.698833 0.26000 9.38000 152.21000 -8.0800 -1.135629e+09 1.232917e+09 5.18000 4.569420e+08 -9.79000 2.380670e+10 1.549858e+10 3.49000 2.022709e+09
2016-12-31 15.888917 -0.06989 -143.27383 -53.34000 24.6300 4.040904e+09 -2.288674e+08 -9.38658 2.131900e+08 10.77000 2.966918e+10 1.028224e+10 -1.85600 2.022709e+09
2017-03-31 15.712500 0.28990 127.28130 258.39300 -13.2278 -9.711650e+08 1.317453e+09 5.11740 7.640580e+08 44.21630 2.574461e+10 1.149584e+10 4.49600 2.022709e+09
2017-06-30 19.197167 0.25760 -6.95960 231.46210 9.7938 -3.235387e+09 1.225763e+09 4.33650 2.532563e+09 75.08140 2.826598e+10 1.257511e+10 3.81530 2.022709e+09
2017-09-30 23.743083 0.38000 42.83700 -21.42130 -20.1544 1.036069e+09 1.750843e+09 7.75770 1.990054e+09 -37.83050 2.256914e+10 1.418689e+10 5.38560 2.022709e+09
2017-12-31 34.003917 0.15830 -37.61390 -26.32080 42.8301 1.039046e+10 1.092283e+09 3.38840 1.466255e+09 -0.65980 3.223553e+10 1.466768e+10 2.12280 2.205436e+09
2016-03-31 6.492583 0.07320 -73.14000 -69.44000 -62.8300 -1.397724e+09 6.400020e+08 11.64000 9.254854e+08 95.15000 5.500350e+09 2.238587e+10 1.57000 2.543815e+09
2016-06-30 6.177417 0.11930 67.22000 48.59000 8.3500 6.076731e+08 1.070220e+09 17.96000 1.375193e+09 77.34000 5.959879e+09 2.279104e+10 2.55000 2.543815e+09
2016-09-30 6.598250 0.16300 33.54000 21.44000 27.3400 1.097621e+10 1.429121e+09 18.83000 1.670046e+09 93.80000 7.589555e+09 2.412827e+10 3.42000 2.543815e+09
2016-12-31 6.704000 0.48400 191.90000 175.46000 116.5000 -5.782313e+09 4.171598e+09 25.39000 4.600311e+09 80.81000 1.643132e+10 2.783806e+10 9.52000 2.805448e+09
2017-03-31 6.803750 0.09230 -80.52760 -75.44800 -62.5386 -7.510819e+09 8.123113e+08 13.19670 1.129467e+09 93.12270 6.155396e+09 2.859505e+10 1.71430 2.805448e+09
2017-06-30 8.113583 0.11900 21.93820 29.59160 24.0133 -1.018259e+10 9.905180e+08 12.97590 1.463694e+09 96.46070 7.633513e+09 2.876039e+10 2.17700 2.805448e+09
... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2016-03-31 13.292000 -0.06520 82.95000 88.22000 26.2300 -9.905389e+07 -3.735655e+07 -3.55000 -3.394274e+07 140.06000 1.052482e+09 5.027835e+08 -1.47000 9.548766e+07
2016-06-30 20.172750 0.00680 102.32000 37.11000 5.7800 2.154776e+08 8.653756e+05 0.08000 -2.134785e+07 32.36000 1.113317e+09 5.064022e+08 0.15000 9.548766e+07
2016-09-30 25.900667 0.08000 880.61282 333.87000 18.7900 6.189952e+07 3.913605e+07 2.96000 4.992677e+07 57.81000 1.322482e+09 5.488654e+08 1.75000 9.548766e+07
2016-12-31 23.780000 0.09800 41.71000 62.72000 5.9500 7.941974e+08 5.546059e+07 3.96000 8.124189e+07 138.17000 1.401104e+09 6.000031e+08 1.71000 1.024114e+08
2017-03-31 32.809833 0.42460 348.59040 316.14230 24.7000 -1.637676e+08 2.487909e+08 14.23960 3.380819e+08 100.00010 1.747176e+09 8.516644e+08 5.62510 1.024114e+08
2017-06-30 34.699167 0.71410 70.61370 48.37720 16.8343 -4.569780e+08 4.244713e+08 20.79420 5.016365e+08 97.53420 2.041301e+09 1.274913e+09 8.83290 1.024114e+08
2017-09-30 52.392000 0.71000 -0.47460 0.62610 15.4893 -5.986665e+08 4.224566e+08 17.91980 5.047771e+08 104.40210 2.357484e+09 1.697863e+09 8.23450 1.024114e+08
2017-12-31 60.570167 0.97459 86.98170 79.70830 48.7714 -5.751204e+08 7.899165e+08 22.52230 9.071263e+08 100.57260 3.507261e+09 2.451631e+09 12.55319 1.462961e+08
2017-06-30 65.165108 0.85250 551.12530 425.46950 67.4591 8.018877e+08 3.585043e+08 14.77720 3.648609e+08 88.93700 2.426069e+09 2.147579e+09 6.80190 1.243390e+08
2017-09-30 65.165108 0.97459 47.92500 77.34540 24.8382 2.840959e+08 5.303175e+08 17.51000 6.470640e+08 97.78170 3.028661e+09 2.678022e+09 9.04540 1.243390e+08
2017-12-31 65.165108 0.84550 -32.97530 -33.28520 -7.3288 9.786372e+08 3.554438e+08 12.66410 4.316878e+08 84.69640 2.806695e+09 2.966904e+09 5.75610 1.910564e+08
2016-12-31 65.165108 0.74930 -21.63000 -20.40000 -13.8400 1.729370e+08 5.119535e+08 15.43000 5.810783e+08 81.10000 3.318619e+09 7.748695e+09 4.86000 3.314493e+08
2017-03-31 64.234083 0.32620 -56.91380 -54.74740 -26.8197 4.605382e+08 2.205816e+08 9.08280 2.629532e+08 92.68790 2.428574e+09 7.971078e+09 1.74870 3.314493e+08
2017-06-30 55.238250 0.66840 107.15050 116.92750 36.8238 8.443235e+08 4.569359e+08 13.75130 5.704178e+08 95.55450 3.322868e+09 7.326335e+09 3.64370 3.314493e+08
2017-09-30 50.384417 0.66300 -0.99280 -5.61190 11.1736 3.536411e+08 4.523996e+08 12.24640 5.384065e+08 99.56310 3.694151e+09 7.778353e+09 3.64270 3.314493e+08
2017-12-31 45.485250 0.74490 12.51590 -28.25140 19.6033 3.034728e+08 5.090213e+08 11.52070 3.862992e+08 60.28630 4.418326e+09 8.276772e+09 3.94060 3.409000e+08
2016-09-30 43.327667 0.66000 -0.25000 -2.52000 13.5200 3.466695e+07 5.455966e+07 13.87000 4.610903e+07 76.72000 3.934187e+08 4.382496e+08 5.76000 2.954503e+07
2016-12-31 63.220000 0.31820 -47.27000 -35.00000 11.9500 4.948543e+07 2.876988e+07 6.53000 2.997250e+07 86.46000 4.404252e+08 4.526373e+08 2.53000 4.591953e+07
2017-03-31 65.165108 0.69490 142.07120 151.40060 2.7122 -1.276328e+07 6.964360e+07 15.39530 7.535105e+07 95.26150 4.523703e+08 5.221263e+08 5.29540 4.591953e+07
2017-06-30 64.560333 0.54250 58.79740 65.60530 7.5063 1.466835e+08 1.105922e+08 22.74030 1.247853e+08 87.69140 4.863266e+08 5.790817e+08 7.88220 4.591953e+07
2017-09-30 64.561333 0.80000 44.02550 45.64300 18.9271 1.053011e+08 1.592810e+08 27.53940 1.817411e+08 75.23730 5.783742e+08 7.390937e+08 10.50100 4.591953e+07
2017-12-31 65.165108 0.28600 -63.56920 -69.92590 -11.3657 -4.151713e+07 5.802732e+07 11.31940 5.465697e+07 86.34940 5.126378e+08 7.675425e+08 3.44990 7.543034e+07
2016-03-31 3.478917 0.00840 28.55000 29.38000 13.2200 2.648065e+08 1.346673e+08 11.64000 2.324076e+08 85.62000 1.157333e+09 3.128069e+09 0.81000 7.860501e+08
2016-06-30 3.649667 0.02200 172.45000 63.27000 -4.7400 2.701510e+08 3.668949e+08 33.28000 3.794460e+08 66.48000 1.102519e+09 3.076703e+09 2.13000 7.860501e+08
2016-09-30 3.999250 0.00430 -81.83000 -65.11000 12.1200 3.306001e+08 6.664981e+07 5.39000 1.323896e+08 67.17000 1.236185e+09 3.148299e+09 0.41000 7.860501e+08
2016-12-31 3.865833 0.02450 576.71000 -94.77000 179.3700 2.049269e+09 4.510263e+08 13.06000 6.925479e+06 -1.25000 3.453534e+09 3.508789e+09 2.27000 8.400989e+08
2017-03-31 4.363417 0.03540 121.42840 823.59474 67.4380 1.427245e+09 9.987004e+08 17.27100 1.493162e+09 98.09960 5.782531e+09 4.106009e+09 3.13740 8.400989e+08
2017-06-30 4.458667 0.01410 -62.87700 -58.42810 1.5543 2.054166e+09 3.707473e+08 6.31340 6.207354e+08 155.72380 5.872410e+09 3.752876e+09 1.25080 8.400989e+08
2017-09-30 7.000000 0.04000 145.89370 114.61300 3.0512 2.185045e+09 9.116443e+08 15.06450 1.332179e+09 100.53950 6.051591e+09 4.522277e+09 2.74850 8.400989e+08
2017-12-31 6.722417 0.05200 44.19260 44.95060 6.4353 2.762356e+09 1.314523e+09 20.40860 1.931002e+09 102.56790 6.441026e+09 5.517441e+09 2.97800 9.681907e+08

2256 rows × 14 columns

df.drop(labels=['price'], axis=1,inplace = True)
#df.insert(0, 'close', close)
df
.dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; }
eps inc_net_profit_annual inc_operation_profit_annual inc_revenue_annual net_operate_cash_flow net_profit net_profit_margin operating_profit operating_profit_to_profit operating_revenue retained_profit roe surplus_reserve_fund
Unnamed: 0
2016-03-31 0.42530 47.54000 43.36000 10.0800 5.926800e+10 6.086000e+09 22.11000 8.014000e+09 87.83000 2.753200e+10 5.901900e+10 3.49000 8.521000e+09
2016-06-30 0.36140 1.97000 1.60000 -1.0700 -3.381803e+10 6.206000e+09 22.79000 8.142000e+09 86.81000 2.723700e+10 6.303600e+10 3.27000 8.521000e+09
2016-09-30 0.37000 3.56000 3.03000 -0.1400 -3.381803e+10 6.427000e+09 23.63000 8.389000e+09 160.49987 2.719900e+10 6.946300e+10 3.30000 8.521000e+09
2016-12-31 0.22600 -39.63000 -37.61000 -5.3400 8.268597e+10 3.880000e+09 15.07000 5.234000e+09 -228.93400 2.574700e+10 6.414300e+10 1.94000 1.078100e+10
2017-03-31 0.36190 60.15460 57.20290 7.6320 -3.381803e+10 6.214000e+09 22.42350 8.228000e+09 92.30860 2.771200e+10 6.948300e+10 3.03190 1.078100e+10
2017-06-30 0.36920 2.02770 0.14580 -4.8751 -1.317200e+10 6.340000e+09 24.05070 8.240000e+09 97.56160 2.636100e+10 7.311000e+10 3.02490 1.078100e+10
2017-09-30 0.38000 4.08520 3.54370 -2.2799 -2.980700e+10 6.599000e+09 25.61720 8.532000e+09 98.04870 2.576000e+10 7.970900e+10 3.07240 1.078100e+10
2017-12-31 0.23510 -38.83920 -38.78340 0.7492 3.920700e+10 4.036000e+09 15.55120 5.223000e+09 102.83630 2.595300e+10 7.966100e+10 1.83390 1.078100e+10
2016-03-31 0.07550 -92.38000 -92.07000 -63.6409 -1.072613e+10 1.249823e+09 8.55000 1.646601e+09 74.77000 1.461131e+10 5.343109e+10 0.83000 2.806877e+10
2016-06-30 0.40930 367.65000 401.52000 186.8470 3.652334e+10 5.844807e+09 9.71000 8.258004e+09 88.03000 6.018398e+10 5.000097e+10 4.56000 2.806877e+10
2016-09-30 0.26000 -28.22000 -28.76000 -29.7800 1.718868e+10 4.195622e+09 9.93000 5.882695e+09 83.25000 4.225951e+10 5.291205e+10 2.94000 2.806877e+10
2016-12-31 0.97459 306.61000 295.00000 186.8470 -3.419766e+09 1.706000e+10 13.82000 2.323648e+10 87.88000 1.234224e+11 6.120027e+10 11.93000 3.254077e+10
2017-03-31 0.06300 -93.49840 -93.29070 -63.6409 -9.523936e+09 1.109171e+09 5.96670 1.559008e+09 82.67640 1.858923e+10 6.189568e+10 0.61160 3.254077e+10
2017-06-30 0.59850 706.35180 676.30410 175.5426 3.137410e+10 8.943819e+09 17.46110 1.210265e+10 88.47160 5.122125e+10 5.978206e+10 5.83140 3.254077e+10
2017-09-30 0.34300 -46.73930 -41.94640 -7.6750 -5.143923e+09 4.763538e+09 10.07300 7.026021e+09 72.91840 4.729003e+10 6.357034e+10 3.30830 3.254077e+10
2017-12-31 0.97459 370.06790 328.76670 166.0109 6.561660e+10 1.935970e+10 17.80010 2.433390e+10 90.18650 1.257966e+11 7.717185e+10 12.55319 3.590007e+10
2016-03-31 0.22860 25.60000 344.30000 -30.9700 3.945521e+09 1.061152e+09 4.85000 3.142410e+08 31.35000 2.185851e+10 1.462773e+10 3.18000 2.022709e+09
2016-06-30 0.19660 6.22000 -42.35000 18.4800 -1.590590e+09 1.127202e+09 4.35000 1.811750e+08 -19.15000 2.589879e+10 1.544462e+10 2.68000 2.022709e+09
2016-09-30 0.26000 9.38000 152.21000 -8.0800 -1.135629e+09 1.232917e+09 5.18000 4.569420e+08 -9.79000 2.380670e+10 1.549858e+10 3.49000 2.022709e+09
2016-12-31 -0.06989 -143.27383 -53.34000 24.6300 4.040904e+09 -2.288674e+08 -9.38658 2.131900e+08 10.77000 2.966918e+10 1.028224e+10 -1.85600 2.022709e+09
2017-03-31 0.28990 127.28130 258.39300 -13.2278 -9.711650e+08 1.317453e+09 5.11740 7.640580e+08 44.21630 2.574461e+10 1.149584e+10 4.49600 2.022709e+09
2017-06-30 0.25760 -6.95960 231.46210 9.7938 -3.235387e+09 1.225763e+09 4.33650 2.532563e+09 75.08140 2.826598e+10 1.257511e+10 3.81530 2.022709e+09
2017-09-30 0.38000 42.83700 -21.42130 -20.1544 1.036069e+09 1.750843e+09 7.75770 1.990054e+09 -37.83050 2.256914e+10 1.418689e+10 5.38560 2.022709e+09
2017-12-31 0.15830 -37.61390 -26.32080 42.8301 1.039046e+10 1.092283e+09 3.38840 1.466255e+09 -0.65980 3.223553e+10 1.466768e+10 2.12280 2.205436e+09
2016-03-31 0.07320 -73.14000 -69.44000 -62.8300 -1.397724e+09 6.400020e+08 11.64000 9.254854e+08 95.15000 5.500350e+09 2.238587e+10 1.57000 2.543815e+09
2016-06-30 0.11930 67.22000 48.59000 8.3500 6.076731e+08 1.070220e+09 17.96000 1.375193e+09 77.34000 5.959879e+09 2.279104e+10 2.55000 2.543815e+09
2016-09-30 0.16300 33.54000 21.44000 27.3400 1.097621e+10 1.429121e+09 18.83000 1.670046e+09 93.80000 7.589555e+09 2.412827e+10 3.42000 2.543815e+09
2016-12-31 0.48400 191.90000 175.46000 116.5000 -5.782313e+09 4.171598e+09 25.39000 4.600311e+09 80.81000 1.643132e+10 2.783806e+10 9.52000 2.805448e+09
2017-03-31 0.09230 -80.52760 -75.44800 -62.5386 -7.510819e+09 8.123113e+08 13.19670 1.129467e+09 93.12270 6.155396e+09 2.859505e+10 1.71430 2.805448e+09
2017-06-30 0.11900 21.93820 29.59160 24.0133 -1.018259e+10 9.905180e+08 12.97590 1.463694e+09 96.46070 7.633513e+09 2.876039e+10 2.17700 2.805448e+09
... ... ... ... ... ... ... ... ... ... ... ... ... ...
2016-03-31 -0.06520 82.95000 88.22000 26.2300 -9.905389e+07 -3.735655e+07 -3.55000 -3.394274e+07 140.06000 1.052482e+09 5.027835e+08 -1.47000 9.548766e+07
2016-06-30 0.00680 102.32000 37.11000 5.7800 2.154776e+08 8.653756e+05 0.08000 -2.134785e+07 32.36000 1.113317e+09 5.064022e+08 0.15000 9.548766e+07
2016-09-30 0.08000 880.61282 333.87000 18.7900 6.189952e+07 3.913605e+07 2.96000 4.992677e+07 57.81000 1.322482e+09 5.488654e+08 1.75000 9.548766e+07
2016-12-31 0.09800 41.71000 62.72000 5.9500 7.941974e+08 5.546059e+07 3.96000 8.124189e+07 138.17000 1.401104e+09 6.000031e+08 1.71000 1.024114e+08
2017-03-31 0.42460 348.59040 316.14230 24.7000 -1.637676e+08 2.487909e+08 14.23960 3.380819e+08 100.00010 1.747176e+09 8.516644e+08 5.62510 1.024114e+08
2017-06-30 0.71410 70.61370 48.37720 16.8343 -4.569780e+08 4.244713e+08 20.79420 5.016365e+08 97.53420 2.041301e+09 1.274913e+09 8.83290 1.024114e+08
2017-09-30 0.71000 -0.47460 0.62610 15.4893 -5.986665e+08 4.224566e+08 17.91980 5.047771e+08 104.40210 2.357484e+09 1.697863e+09 8.23450 1.024114e+08
2017-12-31 0.97459 86.98170 79.70830 48.7714 -5.751204e+08 7.899165e+08 22.52230 9.071263e+08 100.57260 3.507261e+09 2.451631e+09 12.55319 1.462961e+08
2017-06-30 0.85250 551.12530 425.46950 67.4591 8.018877e+08 3.585043e+08 14.77720 3.648609e+08 88.93700 2.426069e+09 2.147579e+09 6.80190 1.243390e+08
2017-09-30 0.97459 47.92500 77.34540 24.8382 2.840959e+08 5.303175e+08 17.51000 6.470640e+08 97.78170 3.028661e+09 2.678022e+09 9.04540 1.243390e+08
2017-12-31 0.84550 -32.97530 -33.28520 -7.3288 9.786372e+08 3.554438e+08 12.66410 4.316878e+08 84.69640 2.806695e+09 2.966904e+09 5.75610 1.910564e+08
2016-12-31 0.74930 -21.63000 -20.40000 -13.8400 1.729370e+08 5.119535e+08 15.43000 5.810783e+08 81.10000 3.318619e+09 7.748695e+09 4.86000 3.314493e+08
2017-03-31 0.32620 -56.91380 -54.74740 -26.8197 4.605382e+08 2.205816e+08 9.08280 2.629532e+08 92.68790 2.428574e+09 7.971078e+09 1.74870 3.314493e+08
2017-06-30 0.66840 107.15050 116.92750 36.8238 8.443235e+08 4.569359e+08 13.75130 5.704178e+08 95.55450 3.322868e+09 7.326335e+09 3.64370 3.314493e+08
2017-09-30 0.66300 -0.99280 -5.61190 11.1736 3.536411e+08 4.523996e+08 12.24640 5.384065e+08 99.56310 3.694151e+09 7.778353e+09 3.64270 3.314493e+08
2017-12-31 0.74490 12.51590 -28.25140 19.6033 3.034728e+08 5.090213e+08 11.52070 3.862992e+08 60.28630 4.418326e+09 8.276772e+09 3.94060 3.409000e+08
2016-09-30 0.66000 -0.25000 -2.52000 13.5200 3.466695e+07 5.455966e+07 13.87000 4.610903e+07 76.72000 3.934187e+08 4.382496e+08 5.76000 2.954503e+07
2016-12-31 0.31820 -47.27000 -35.00000 11.9500 4.948543e+07 2.876988e+07 6.53000 2.997250e+07 86.46000 4.404252e+08 4.526373e+08 2.53000 4.591953e+07
2017-03-31 0.69490 142.07120 151.40060 2.7122 -1.276328e+07 6.964360e+07 15.39530 7.535105e+07 95.26150 4.523703e+08 5.221263e+08 5.29540 4.591953e+07
2017-06-30 0.54250 58.79740 65.60530 7.5063 1.466835e+08 1.105922e+08 22.74030 1.247853e+08 87.69140 4.863266e+08 5.790817e+08 7.88220 4.591953e+07
2017-09-30 0.80000 44.02550 45.64300 18.9271 1.053011e+08 1.592810e+08 27.53940 1.817411e+08 75.23730 5.783742e+08 7.390937e+08 10.50100 4.591953e+07
2017-12-31 0.28600 -63.56920 -69.92590 -11.3657 -4.151713e+07 5.802732e+07 11.31940 5.465697e+07 86.34940 5.126378e+08 7.675425e+08 3.44990 7.543034e+07
2016-03-31 0.00840 28.55000 29.38000 13.2200 2.648065e+08 1.346673e+08 11.64000 2.324076e+08 85.62000 1.157333e+09 3.128069e+09 0.81000 7.860501e+08
2016-06-30 0.02200 172.45000 63.27000 -4.7400 2.701510e+08 3.668949e+08 33.28000 3.794460e+08 66.48000 1.102519e+09 3.076703e+09 2.13000 7.860501e+08
2016-09-30 0.00430 -81.83000 -65.11000 12.1200 3.306001e+08 6.664981e+07 5.39000 1.323896e+08 67.17000 1.236185e+09 3.148299e+09 0.41000 7.860501e+08
2016-12-31 0.02450 576.71000 -94.77000 179.3700 2.049269e+09 4.510263e+08 13.06000 6.925479e+06 -1.25000 3.453534e+09 3.508789e+09 2.27000 8.400989e+08
2017-03-31 0.03540 121.42840 823.59474 67.4380 1.427245e+09 9.987004e+08 17.27100 1.493162e+09 98.09960 5.782531e+09 4.106009e+09 3.13740 8.400989e+08
2017-06-30 0.01410 -62.87700 -58.42810 1.5543 2.054166e+09 3.707473e+08 6.31340 6.207354e+08 155.72380 5.872410e+09 3.752876e+09 1.25080 8.400989e+08
2017-09-30 0.04000 145.89370 114.61300 3.0512 2.185045e+09 9.116443e+08 15.06450 1.332179e+09 100.53950 6.051591e+09 4.522277e+09 2.74850 8.400989e+08
2017-12-31 0.05200 44.19260 44.95060 6.4353 2.762356e+09 1.314523e+09 20.40860 1.931002e+09 102.56790 6.441026e+09 5.517441e+09 2.97800 9.681907e+08

2256 rows × 13 columns

from sklearn.decomposition import PCA
from sklearn.model_selection import train_test_split
#PCA降维
def pca_analysis(data,n_components='mle'):
    index = data.index
    model = PCA(n_components=n_components)
    model.fit(data)
    data_pca = model.transform(data)
    df = pd.DataFrame(data_pca,index=index)
    return df
data_pca = pca_analysis(df,n_components=0.95)
data_pca
.dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; }
0 1 2
Unnamed: 0
2016-03-31 4.343270e+10 -1.026006e+10 4.902812e+10
2016-06-30 3.287826e+10 -1.140296e+10 -4.315701e+10
2016-09-30 3.790962e+10 -1.440138e+10 -4.418137e+10
2016-12-31 5.024880e+10 -1.478877e+10 7.160921e+10
2017-03-31 3.883285e+10 -1.456683e+10 -4.409100e+10
2017-06-30 4.397330e+10 -1.759138e+10 -2.427773e+10
2017-09-30 4.642744e+10 -2.097654e+10 -4.166044e+10
2017-12-31 5.615690e+10 -2.129316e+10 2.637746e+10
2016-03-31 2.711036e+10 -2.272108e+10 -1.687393e+10
2016-06-30 5.590668e+10 1.651445e+10 2.711221e+10
2016-09-30 4.571670e+10 3.596123e+08 8.816557e+09
2016-12-31 9.497311e+10 6.315073e+10 -1.820863e+10
2017-03-31 3.727789e+10 -2.443916e+10 -1.703291e+10
2017-06-30 5.986892e+10 3.056683e+09 2.108105e+10
2017-09-30 5.485090e+10 -1.302605e+09 -1.495390e+10
2017-12-31 1.199402e+11 5.610649e+10 4.711828e+10
2016-03-31 -5.016827e+09 8.076258e+09 1.970677e+09
2016-06-30 -3.075231e+09 1.117917e+10 -3.843394e+09
2016-09-30 -4.036353e+09 9.365956e+09 -3.289650e+09
2016-12-31 -4.388740e+09 1.672073e+10 2.316428e+09
2017-03-31 -6.097973e+09 1.282599e+10 -2.623242e+09
2017-06-30 -4.142437e+09 1.442046e+10 -5.220753e+09
2017-09-30 -5.253224e+09 8.822691e+09 -9.293062e+08
2017-12-31 1.524061e+09 1.667456e+10 7.657516e+09
2016-03-31 -8.125639e+09 -9.416483e+09 -3.510938e+09
2016-06-30 -7.219796e+09 -9.265356e+09 -1.653201e+09
2016-09-30 -3.770571e+09 -8.630082e+09 8.219842e+09
2016-12-31 1.759500e+09 -2.950616e+09 -9.516879e+09
2017-03-31 -3.720857e+09 -1.173234e+10 -1.053979e+10
2017-06-30 -3.172705e+09 -1.054898e+10 -1.329641e+10
... ... ... ...
2016-03-31 -2.818630e+10 -2.436792e+09 1.406017e+09
2016-06-30 -2.810275e+10 -2.391915e+09 1.709901e+09
2016-09-30 -2.797513e+10 -2.236869e+09 1.536625e+09
2016-12-31 -2.778218e+10 -2.204958e+09 2.243209e+09
2017-03-31 -2.751445e+10 -2.033910e+09 1.228395e+09
2017-06-30 -2.705078e+10 -1.988206e+09 8.466173e+08
2017-09-30 -2.657533e+10 -1.913468e+09 6.215314e+08
2017-12-31 -2.531843e+10 -1.325950e+09 4.386200e+08
2017-06-30 -2.599141e+10 -2.074676e+09 1.930794e+09
2017-09-30 -2.530689e+10 -1.819447e+09 1.289378e+09
2017-12-31 -2.510212e+10 -2.150891e+09 1.954085e+09
2016-12-31 -2.115495e+10 -3.952395e+09 3.753818e+08
2017-03-31 -2.144472e+10 -4.788801e+09 6.927114e+08
2017-06-30 -2.138881e+10 -3.759743e+09 1.103803e+09
2017-09-30 -2.091530e+10 -3.646689e+09 5.286290e+08
2017-12-31 -2.015903e+10 -3.260688e+09 3.607933e+08
2016-09-30 -2.857067e+10 -2.954438e+09 1.579328e+09
2016-12-31 -2.853049e+10 -2.924369e+09 1.590736e+09
2017-03-31 -2.847343e+10 -2.948562e+09 1.515527e+09
2017-06-30 -2.838206e+10 -2.950828e+09 1.658926e+09
2017-09-30 -2.820804e+10 -2.949721e+09 1.584637e+09
2017-12-31 -2.824783e+10 -3.016628e+09 1.447283e+09
2016-03-31 -2.579608e+10 -3.756812e+09 1.366496e+09
2016-06-30 -2.584040e+10 -3.792631e+09 1.373294e+09
2016-09-30 -2.574046e+10 -3.694048e+09 1.427834e+09
2016-12-31 -2.401904e+10 -2.023038e+09 2.925835e+09
2017-03-31 -2.228576e+10 -3.958155e+08 2.024033e+09
2017-06-30 -2.252161e+10 -1.105224e+08 2.731423e+09
2017-09-30 -2.172586e+10 -3.580749e+08 2.694390e+09
2017-12-31 -2.055700e+10 -5.614782e+08 3.061337e+09

2256 rows × 3 columns

data_pca.insert( 0, 'price', price)
data_pca
.dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; }
price 0 1 2
Unnamed: 0
2016-03-31 8.271833 4.343270e+10 -1.026006e+10 4.902812e+10
2016-06-30 8.370500 3.287826e+10 -1.140296e+10 -4.315701e+10
2016-09-30 8.921500 3.790962e+10 -1.440138e+10 -4.418137e+10
2016-12-31 8.975500 5.024880e+10 -1.478877e+10 7.160921e+10
2017-03-31 9.028333 3.883285e+10 -1.456683e+10 -4.409100e+10
2017-06-30 8.753667 4.397330e+10 -1.759138e+10 -2.427773e+10
2017-09-30 10.768917 4.642744e+10 -2.097654e+10 -4.166044e+10
2017-12-31 12.431917 5.615690e+10 -2.129316e+10 2.637746e+10
2016-03-31 21.820000 2.711036e+10 -2.272108e+10 -1.687393e+10
2016-06-30 21.820000 5.590668e+10 1.651445e+10 2.711221e+10
2016-09-30 20.037500 4.571670e+10 3.596123e+08 8.816557e+09
2016-12-31 23.069833 9.497311e+10 6.315073e+10 -1.820863e+10
2017-03-31 19.356917 3.727789e+10 -2.443916e+10 -1.703291e+10
2017-06-30 19.283500 5.986892e+10 3.056683e+09 2.108105e+10
2017-09-30 23.069000 5.485090e+10 -1.302605e+09 -1.495390e+10
2017-12-31 27.828917 1.199402e+11 5.610649e+10 4.711828e+10
2016-03-31 14.935583 -5.016827e+09 8.076258e+09 1.970677e+09
2016-06-30 13.704167 -3.075231e+09 1.117917e+10 -3.843394e+09
2016-09-30 14.698833 -4.036353e+09 9.365956e+09 -3.289650e+09
2016-12-31 15.888917 -4.388740e+09 1.672073e+10 2.316428e+09
2017-03-31 15.712500 -6.097973e+09 1.282599e+10 -2.623242e+09
2017-06-30 19.197167 -4.142437e+09 1.442046e+10 -5.220753e+09
2017-09-30 23.743083 -5.253224e+09 8.822691e+09 -9.293062e+08
2017-12-31 34.003917 1.524061e+09 1.667456e+10 7.657516e+09
2016-03-31 6.492583 -8.125639e+09 -9.416483e+09 -3.510938e+09
2016-06-30 6.177417 -7.219796e+09 -9.265356e+09 -1.653201e+09
2016-09-30 6.598250 -3.770571e+09 -8.630082e+09 8.219842e+09
2016-12-31 6.704000 1.759500e+09 -2.950616e+09 -9.516879e+09
2017-03-31 6.803750 -3.720857e+09 -1.173234e+10 -1.053979e+10
2017-06-30 8.113583 -3.172705e+09 -1.054898e+10 -1.329641e+10
... ... ... ... ...
2016-03-31 13.292000 -2.818630e+10 -2.436792e+09 1.406017e+09
2016-06-30 20.172750 -2.810275e+10 -2.391915e+09 1.709901e+09
2016-09-30 25.900667 -2.797513e+10 -2.236869e+09 1.536625e+09
2016-12-31 23.780000 -2.778218e+10 -2.204958e+09 2.243209e+09
2017-03-31 32.809833 -2.751445e+10 -2.033910e+09 1.228395e+09
2017-06-30 34.699167 -2.705078e+10 -1.988206e+09 8.466173e+08
2017-09-30 52.392000 -2.657533e+10 -1.913468e+09 6.215314e+08
2017-12-31 60.570167 -2.531843e+10 -1.325950e+09 4.386200e+08
2017-06-30 65.165108 -2.599141e+10 -2.074676e+09 1.930794e+09
2017-09-30 65.165108 -2.530689e+10 -1.819447e+09 1.289378e+09
2017-12-31 65.165108 -2.510212e+10 -2.150891e+09 1.954085e+09
2016-12-31 65.165108 -2.115495e+10 -3.952395e+09 3.753818e+08
2017-03-31 64.234083 -2.144472e+10 -4.788801e+09 6.927114e+08
2017-06-30 55.238250 -2.138881e+10 -3.759743e+09 1.103803e+09
2017-09-30 50.384417 -2.091530e+10 -3.646689e+09 5.286290e+08
2017-12-31 45.485250 -2.015903e+10 -3.260688e+09 3.607933e+08
2016-09-30 43.327667 -2.857067e+10 -2.954438e+09 1.579328e+09
2016-12-31 63.220000 -2.853049e+10 -2.924369e+09 1.590736e+09
2017-03-31 65.165108 -2.847343e+10 -2.948562e+09 1.515527e+09
2017-06-30 64.560333 -2.838206e+10 -2.950828e+09 1.658926e+09
2017-09-30 64.561333 -2.820804e+10 -2.949721e+09 1.584637e+09
2017-12-31 65.165108 -2.824783e+10 -3.016628e+09 1.447283e+09
2016-03-31 3.478917 -2.579608e+10 -3.756812e+09 1.366496e+09
2016-06-30 3.649667 -2.584040e+10 -3.792631e+09 1.373294e+09
2016-09-30 3.999250 -2.574046e+10 -3.694048e+09 1.427834e+09
2016-12-31 3.865833 -2.401904e+10 -2.023038e+09 2.925835e+09
2017-03-31 4.363417 -2.228576e+10 -3.958155e+08 2.024033e+09
2017-06-30 4.458667 -2.252161e+10 -1.105224e+08 2.731423e+09
2017-09-30 7.000000 -2.172586e+10 -3.580749e+08 2.694390e+09
2017-12-31 6.722417 -2.055700e+10 -5.614782e+08 3.061337e+09

2256 rows × 4 columns

data_pca
#df=data_pro
X2= data_pca.values[:, 1:]
Y2 =data_pca.values[:, 0]
X2.shape  #划分 x和标签y 
(2256, 3)
import numpy as np
import matplotlib.pyplot as plt

sampleRatio=0.2               #划分训练集和测试集各一半
m=len(X)
sampleBoundary=int(m*sampleRatio)
myshuffle=list(range(m))      #注意Python3中range()返回range对象而不是数组对象,要将其转为序列
np.random.shuffle(myshuffle)  #shuffle()函数将序列内的元素全部随机排序
#分别取出训练集和测试集的数据
train_fea2= X2[myshuffle[sampleBoundary:]]    #前一半数据集作为训练集
train_tar2= Y2[myshuffle[sampleBoundary:]]

test_fea2=  X2[myshuffle[:sampleBoundary]]     #后一半数据作为测试集
test_tar2=  Y2[myshuffle[:sampleBoundary]]
train_fea2.shape
(1444, 3)
from sklearn import linear_model
#使用最小二乘线性回归进行拟合,导入相应的模块
lr=linear_model.LinearRegression()

lr.fit(train_fea2,train_tar2)  #拟合
y_pred=lr.predict(test_fea2)       #得到预测值集合y
plt.scatter(y_pred,test_tar2)      #画出散点图,横轴是预测值,纵轴是真实值
plt.plot([y_pred.min(), y_pred.max()], [y_pred.min(), y_pred.max()], 'b',lw=5) #直线的起点为(y.min(),y.min()),终点是(y.max(),y.max())
plt.show()
coef=lr.coef_                #获得该回该方程的回归系数与截距
intercept=lr.intercept_
print("预测方程回归系数:",coef)
print("预测方程截距:",intercept)


score=lr.score(test_fea2,test_tar2)    #对得到的模型打分
print("对该模型的评分是:%.5f" %score)
#--------------------- 
预测方程回归系数: [-4.16038761e-11 -7.75401816e-11 -8.45493194e-12]
预测方程截距: 17.425738170000557
对该模型的评分是:0.03062
 
分享到:
举报财经168客户端下载

全部回复

0/140

投稿 您想发表你的观点和看法?

更多人气分析师

  • 张亦巧

    人气2184文章4145粉丝45

    暂无个人简介信息

  • 梁孟梵

    人气2176文章3177粉丝39

    qq:2294906466 了解群指导添加微信mfmacd

  • 指导老师

    人气1864文章4423粉丝52

    暂无个人简介信息

  • 李冉晴

    人气2320文章3821粉丝34

    李冉晴,专业现贷实盘分析师。

  • 王启蒙现货黄金

    人气296文章3140粉丝8

    本人做分析师以来,并专注于贵金属投资市场,尤其是在现货黄金...

  • 张迎妤

    人气1896文章3305粉丝34

    个人专注于行情技术分析,消息面解读剖析,给予您第一时间方向...

  • 金泰铬J

    人气2328文章3925粉丝51

    投资问答解咨询金泰铬V/信tgtg67即可获取每日的实时资讯、行情...

  • 金算盘

    人气2696文章7761粉丝125

    高级分析师,混过名校,厮杀于股市和期货、证券市场多年,专注...

  • 金帝财神

    人气4760文章8329粉丝119

    本文由资深分析师金帝财神微信:934295330,指导黄金,白银,...

FX168财经

FX168财经学院

FX168财经

FX168北美