Search⌘ K
AI Features

Generalized Linear Models

Explore the fundamentals of generalized linear models by understanding how nonlinear feature transformations enable modeling complex regression and classification tasks. Learn how mapping input features to higher-dimensional spaces allows linear methods to capture curved patterns and class boundaries, providing a foundation for more advanced machine learning techniques.

In many real-world problems, the relationship between input features and the target variable is not strictly linear. Linear models often fall short when data contains interactions, curved patterns, or complex class boundaries. Generalized linear models (GLMs) offer a flexible extension, maintaining a linear model structure while allowing for nonlinear transformations of the input features. By mapping the original data into a transformed feature space using basis functions, GLMs enable both regression and classification models to capture richer structures without giving up the simplicity and interpretability of linear methods.

This lesson explores how nonlinearity is introduced through basis functions and demonstrates how generalized linear models behave in both regression and classification settings.

Generalized linear model for regression

A regression model that is linear in parameters w\bold w, and might not necessarily be linear in the input features x\bold x, is known as a generalized linear model for regression. This is achieved by mapping the original input features x\mathbf{x} into a higher-dimensional feature space using a non-linear set of basis functions, ϕ(x)\phi(\mathbf{x}).

The model is defined as:

fw(x)=wTϕ(x)f_\bold{w}(\bold x)=\bold w^T\phi(\bold x)

Here,

  • Parameters (w\mathbf{w}): This is the vector of coefficients that is learned during training, and the model is linear with respect to these parameters.

  • Basis functions (ϕ(x)\phi(\mathbf{x})): This function transforms the original features x\mathbf{x}. For example, if x=[x1]\mathbf{x} = [x_1], then ϕ(x)\phi(\mathbf{x}) could be [1,x1,x12][1, x_1, x_1^2].

Note: A GLM is linear in the transformed features ϕ(x)\phi(\mathbf{x}), but is typically nonlinear in the original input features x\mathbf{x}. This non-linear mapping allows the model to fit complex, curved data patterns using simple linear methods.

Nonlinear transformations in regression

Suppose we are building a model to predict a student’s total marks (yy) based on hours studied (x1x_1) and class attendance (x2x_2). A simple linear model would look like:

y=w0+w1x1+w2x2y = w_0 + w_1x_1 + w_2x_2 ...