线性回归只提取系数和常数

时间:2017-06-15 01:04:18

标签: python linear-regression

我编写了一个多线性回归模型的代码。但是当我使用results.summary() Python吐出这整件事时

if i >1:
        xxx = sm.add_constant(xxx)
        results = sm.OLS(y_variable_holder, xxx).fit()
        print (results.summary())


 OLS Regression Results                            
==============================================================================
Dep. Variable:                      y   R-squared:                       0.001
Model:                            OLS   Adj. R-squared:                  0.000
Method:                 Least Squares   F-statistic:                     1.051
Date:                Wed, 14 Jun 2017   Prob (F-statistic):              0.369
Time:                        20:01:26   Log-Likelihood:                 6062.6
No. Observations:                2262   AIC:                        -1.212e+04
Df Residuals:                    2258   BIC:                        -1.209e+04
Df Model:                           3                                         
==============================================================================
                 coef    std err          t      P>|t|      [95.0% Conf. Int.]
------------------------------------------------------------------------------
const         -0.0002      0.000     -0.476      0.634        -0.001     0.001
x1            -0.0001      0.001     -0.218      0.828        -0.001     0.001
x2          8.445e-06   2.31e-05      0.366      0.714     -3.68e-05  5.37e-05
x3            -0.0026      0.003     -0.941      0.347        -0.008     0.003
==============================================================================
Omnibus:                      322.021   Durbin-Watson:                   2.255
Prob(Omnibus):                  0.000   Jarque-Bera (JB):             4334.191
Skew:                          -0.097   Prob(JB):                         0.00
Kurtosis:                       9.779   Cond. No.                         127.
==============================================================================

我希望Python只吐出常数和系数。例如,期望的输出:

python output: 
[-0.0002]
[-0.0001]
[8.445e-06]
[ -0.0026]

我怎样才能做到这一点?我不需要整个摘要只是恒定/有效。

1 个答案:

答案 0 :(得分:1)

我明白了。答案是results_bucket.append(results.params)