Congratulations!

Generalized Linear Models in Python

Ita Cirovic Donev

Data Science Consultant

MODEL

  • Data $\rightarrow$
  • Link function $\rightarrow$
  • Model $\rightarrow$
  • 1-unit increase in $x \rightarrow$

LOGISTIC REGRESSION

  • Binary
  • Logit
  • $logit(y) = \beta_0+\beta_1x_1$
  • increases $\color{red}{\text{log odds }}$ by $\beta_1$

LINEAR MODEL

  • Continuous
  • Identity
  • $y = \beta_0+\beta_1x_1$
  • increases $\color{red}{y}$ by $\beta_1$

POISSON REGRESSION

  • Count
  • Logarithm
  • $log(\lambda) = \beta_0+\beta_1x_1$
  • $\color{red}{\text{multiplies } \lambda}$ by $exp(\beta_1)$
Generalized Linear Models in Python

MAIN PYTHON FUNCTIONS

  • Fit the model
    statmodels $\rightarrow$

LINEAR MODEL

glm('y ~ x', data)
glm('y ~ x', data, 
    family = sm.families.Gaussian())

LOGISTIC REGRESSION

glm('y ~ x', data, 
    family = sm.families.Binomial())

POISSON REGRESSION

glm('y ~ x', data, 
    family = sm.families.Poisson())
Generalized Linear Models in Python

Next steps...

  • DataCamp courses
  • Excellent reference books
    • Regression Modeling Strategies by Frank E. Harrell, Jr.
    • An Introduction to Categorical Data Analysis by Alan Agresti
    • Applied Predictive Modeling by Max Kuhn and Kjell Johnson
Generalized Linear Models in Python

Happy modeling!

Generalized Linear Models in Python

Preparing Video For Download...