Generalized Linear Models › Common GLM Types
Machine Learning from ScratchAll chapters Generalized Linear Models › Common GLM TypesOne section · Sections in this chapter3 / 12 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Each GLM type is defined by its choice of link function and probability distribution. The link function acts as a bridge between the linear predictor (the weighted sum of your features) and the expected value of the response variable. By selecting an appropriate link function and distribution, GLMs allow us to model a wide variety of data types using a unified framework.
In the following sections, we'll briefly introduce the most common GLM types: linear and logistic regression, followed by Poisson regression, to illustrate how the link function and model structure work together. Each of these models is covered in greater detail in its own dedicated chapter, where you'll find deeper mathematical explanations, practical examples, and implementation guidance. For now, consider this a high-level overview to set the stage for those more in-depth explorations.



Linear Regression (Identity Link)
When the response variable is continuous and normally distributed, and the relationship between the predictors and the response is assumed to be linear, we use the identity link function. This is the classic linear regression model.
- Distribution: Normal (Gaussian)
- Link function: (identity)
- Model:
where:
- is the expected value of the response variable given the predictors (the conditional mean we're modeling)
- is the intercept (the expected response when all predictors equal zero)
- are the regression coefficients (quantify the linear effect of each predictor)
- are the predictor variables (the feature values)
- is the number of predictors
The identity link means that the expected response is modeled directly as a linear function of the features. This is the standard linear regression we've covered in previous sections, and it is the basis for all GLMs.
When to use: Use linear regression when your outcome is continuous with no fixed bounds and follows an approximately normal distribution. Examples include predicting house prices, heights, or temperatures.
Logistic Regression (Logit Link)
When the response variable is binary (e.g., success/failure, yes/no, 0/1), logistic regression is the appropriate GLM. It uses the logit link function to model the probability of success.
- Distribution: Binomial
- Link function: (logit)
- Model:
where:
- is the probability that the response variable equals 1 (success) given predictors (the parameter we're modeling)
- is the odds of success (the ratio of the probability of success to the probability of failure)
- is the log-odds or logit (the natural logarithm of the odds)
- is the intercept (the log-odds when all predictors equal zero)
- are the regression coefficients (represent the change in log-odds for a one-unit increase in each predictor)
- are the predictor variables (the feature values)
The logit link transforms probabilities (which are constrained to be between 0 and 1) to the entire real line, allowing us to model them with a linear predictor.
When to use: Use logistic regression for binary classification tasks, such as predicting whether a customer will buy a product (yes/no), or whether an email is spam (spam/not spam).
Poisson Regression (Log Link)
For modeling count data.where the response variable represents the number of times an event occurs.Poisson regression is used. It employs the log link function to ensure that the predicted counts are non-negative.
- Distribution: Poisson
- Link function: (log)
- Model:
where:
- is the expected count (mean of the Poisson distribution) given predictors (the rate parameter we're modeling)
- is the natural logarithm of the expected count (the link function applied to the mean)
- is the intercept (the log of the expected count when all predictors equal zero)
- are the regression coefficients (represent the change in log-count for a one-unit increase in each predictor)
- are the predictor variables (the feature values)
The log link ensures that the predicted mean is positive. By inverting the log link, we get:
where:
- is Euler's number (approximately 2.718)
- The exponential function is positive for any real value
- This ensures , which is necessary for count data (counts cannot be negative)
When to use: Use Poisson regression when your outcome is a count (e.g., number of customer visits, number of accidents, number of emails received in an hour), and the counts are non-negative integers.
Linear and logistic regression, together with Poisson regression, are the most common and foundational examples of GLMs. Each is defined by its choice of distribution and link function, allowing you to tailor the model to the nature of your response variable.
The models and link functions described above are all classic examples of Generalized Linear Models (GLMs). While this list is not exhaustive, these are among the most commonly used GLM types in practice. We will explore the mathematical details and reasoning behind the most popular forms and link functions in the following sections.