मल्टिवेरिएबल लॉजिस्टिक रिग्रेशन

Python में Generalized Linear Models

Ita Cirovic Donev

Data Science Consultant

मल्टिवेरिएबल सेटिंग

  • मॉडल फॉर्मूला $$ \text{logit}(y) = \beta_0+\beta_1\color{red}{x_1} $$
Python में Generalized Linear Models

मल्टिवेरिएबल सेटिंग

  • मॉडल फॉर्मूला $$ \text{logit}(y) = \color{blue}{\beta_0}+\color{blue}{\beta_1}\color{red}{x_1} $$
Python में Generalized Linear Models

मल्टिवेरिएबल सेटिंग

  • मॉडल फॉर्मूला $$ \text{logit}(y) = \beta_0+\beta_1x_1 + \beta_2\color{red}{x_2} + ... + \beta_p \color{red}{x_p} $$
Python में Generalized Linear Models

मल्टिवेरिएबल सेटिंग

  • मॉडल फॉर्मूला $$ \text{logit}(y) = \beta_0+\beta_1x_1 + \color{blue}{\beta_2}\color{red}{x_2} + ... + \color{blue}{\beta_p}\color{red}{x_p} $$

  • Python में

    model = glm('y ~ x1 + x2 + x3 + x4', 
              data = my_data, 
              family = sm.families.Binomial()).fit()
    
Python में Generalized Linear Models

उदाहरण - कुआँ बदलना

formula = 'switch ~ distance100 + arsenic'
wells_fit = glm(formula = formula, data = wells, 
                family = sm.families.Binomial()).fit()
===============================================================================
                  coef    std err          z      P>|z|      [0.025      0.975]
-------------------------------------------------------------------------------
Intercept       0.0027      0.079      0.035      0.972      -0.153       0.158
distance100    -0.8966      0.104     -8.593      0.000      -1.101      -0.692
arsenic         0.4608      0.041     11.134      0.000       0.380       0.542
===============================================================================
Python में Generalized Linear Models

उदाहरण - कुआँ बदलना

                  coef    std err          z      P>|z|      [0.025      0.975]
-------------------------------------------------------------------------------
Intercept       0.0027      0.079      0.035      0.972      -0.153       0.158
distance100    -0.8966      0.104     -8.593      0.000      -1.101      -0.692
arsenic         0.4608      0.041     11.134      0.000       0.380       0.542
  • दोनों कोएफिशिएंट सांख्यिकीय रूप से महत्वपूर्ण हैं
  • कोएफिशिएंट के संकेत तार्किक हैं
  • distance100 में 1 यूनिट बदलाव से logit में -0.89 का अंतर आता है
  • arsenic में 1 यूनिट बदलाव से logit में 0.46 का सकारात्मक अंतर आता है
Python में Generalized Linear Models

एक वैरिएबल जोड़ने का प्रभाव

  • arsenic वैरिएबल का असर
  • distance100 -0.62 से -0.89 हो जाता है
  • सुरक्षित कुएँ से दूरी बढ़े तो
    • उच्च arsenic स्तर की संभावना बढ़ती है
                  coef    std err 
---------------------------------
Intercept       0.0027      0.079
distance100    -0.8966      0.104
arsenic         0.4608      0.041  
                  coef    std err
---------------------------------
Intercept       0.6060      0.060
distance100    -0.6291      0.097  
Python में Generalized Linear Models

मल्टिकॉलीनियरिटी

  • वे वैरिएबल जो अन्य मॉडल वैरिएबल्स से correlated हों

दो वैरिएबल्स की संरचना, सहसंबंध 0.8, 0.4, 0, -0.4 और -0.8 पर.

  • कोएफिशिएंट्स के standard errors बढ़ जाते हैं
    • कोएफिशिएंट सांख्यिकीय रूप से महत्वपूर्ण न भी हों
1 https://en.wikipedia.org/wiki/Correlation_and_dependence
Python में Generalized Linear Models

मल्टिकॉलीनियरिटी की मौजूदगी?

क्या देखें?

  • कोएफिशिएंट महत्वपूर्ण नहीं, पर वैरिएबल का $y$ से उच्च सहसंबंध हो
  • वैरिएबल जोड़ने/हटाने से कोएफिशिएंट्स में बड़ा बदलाव हो
  • कोएफिशिएंट का संकेत तार्किक न हो
  • वैरिएबल्स में उच्च pairwise correlation हो
Python में Generalized Linear Models

Variance inflation factor (VIF)

  • मल्टिकॉलीनियरिटी के लिए सबसे प्रचलित डायग्नोस्टिक
    • हर explanatory वैरिएबल के लिए निकाला जाता है
    • कोएफिशिएंट के variance में कितनी inflation है
  • सुझाया थ्रेशहोल्ड VIF > 2.5
  • Python में
from statsmodels.stats.outliers_influence import variance_inflation_factor
Python में Generalized Linear Models

अभ्यास करते हैं!

Python में Generalized Linear Models

Preparing Video For Download...