如何在python中从glm模型获取系数

问题描述 投票:0回答:1

我已经用Python训练了以下glm模型:

fitGlm = smf.glm( listOfInModelFeatures,
              family=sm.families.Binomial(),data=train, freq_weights = train['model_weight']).fit()

然后我生成了训练模型的摘要:

    print(fitGlm.summary())

给出以下报告:

                 Generalized Linear Model Regression Results                  
==============================================================================
Dep. Variable:                 Target   No. Observations:              1065046
Model:                            GLM   Df Residuals:               4361436.81
Model Family:                Binomial   Df Model:                            8
Link Function:                  Logit   Scale:                          1.0000
Method:                          IRLS   Log-Likelihood:            -6.1870e+05
Date:                Wed, 21 Aug 2024   Deviance:                   1.2374e+06
Time:                        10:27:37   Pearson chi2:                 4.01e+06
No. Iterations:                     8   Pseudo R-squ. (CS):             0.1479
Covariance Type:            nonrobust                                         
===============================================================================
                  coef    std err          z      P>|z|      [0.025      0.975]
-------------------------------------------------------------------------------
Intercept       3.2619      0.003   1126.728      0.000       3.256       3.268
e1_a_11_sp      0.9318      0.004    256.254      0.000       0.925       0.939
sp_g_37         0.5850      0.006    102.522      0.000       0.574       0.596
sp_f3_35        0.6510      0.005    135.114      0.000       0.642       0.660
e1_a_07_sp      0.4930      0.006     79.698      0.000       0.481       0.505
e1_e_02_sp      0.9956      0.008    120.253      0.000       0.979       1.012
e1_b_03_sp      0.7493      0.013     56.539      0.000       0.723       0.775
e2_k_02_spa     0.4996      0.014     34.512      0.000       0.471       0.528
ea5_s_01_sp     0.3305      0.008     41.524      0.000       0.315       0.346
===============================================================================

问题:如何获取每个特征的系数列表(包括截距)? 我的意思是,我怎样才能得到这样的东西?

[3.2619,0.9318,0.5850,0.6510,0.4930,0.9956,0.7493,0.4996,0.3305]

提前致谢。

python list glm coefficients
1个回答
0
投票

已排序!

我需要使用这样的东西: 打印(fitGlm.params [“e1_a_11_sp”]) 打印(fitGlm.params [“sp_g_37”])

© www.soinside.com 2019 - 2024. All rights reserved.