0

I have trained the following glm model in Python:

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

I have then produced the summary of the trained model:

    print(fitGlm.summary())

which gives the following report:

                 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
===============================================================================

Question: how do I get the list of coefficients for each feature (incl. the intercept)? I mean, how do I get something like this?

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

Thanks in advance.

1 Answer 1

0

Sorted!

I need to use something like this:

print(fitGlm.params["e1_a_11_sp"])
print(fitGlm.params["sp_g_37"])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.