Learning outcomes

After completing this lesson, you will be able to:

Lesson challenge

How can we build a nonlinear model that remains useful for prediction while allowing people to inspect how each feature contributes?

1. From interpretable nonlinear models to additive models

The previous lessons introduced thresholds, trees and rules as ways to represent nonlinear patterns. Trees create stepwise regions, while long rule lists become difficult to review. Another approach represents a prediction as a sum of separate feature functions. This is the idea behind Generalized Additive Models (GAMs).Instead of assigning one constant coefficient to each feature, a GAM estimates a function describing how that feature contributes across its range. The overall structure remains additive: each contribution can be inspected separately and then summed.Additivity is both a restriction and a source of clarity. Without interactions, the contribution of temperature does not depend on vibration. This is easier to inspect, but may be insufficient when combinations of features carry additional information.
Generalized Additive Model (GAM)A model in which the linear predictor of a generalized linear model is replaced by a sum of feature-specific functions, with a link function connecting it to the target.

2. The structure of a GAM

A typical GAM is written as g(E[y]) = β₀ + f₁(x₁) + f₂(x₂) + … + fₚ(xₚ). Here β₀ is the intercept, fⱼ is the shape function for feature xⱼ, and g is the link function. In Gaussian regression the link may be the identity; logistic classification commonly uses the logit link.Each fⱼ describes a feature contribution on the linear-predictor scale. For example, a temperature function may rise slowly, become steeper, and then level off. The model is not restricted to a constant change in prediction for every one-unit increase in temperature.In practice, shape functions may use smoothing splines, local smoothers or other basis representations. Complexity is controlled through penalties on excessive wiggliness, the number of knots or basis functions, and smoothing settings.
GAM decomposes a prediction into feature functionsThree separate feature shape functions are added to an intercept, then a link function transforms the sum into a prediction.Additive structure of a GAMf₁(vibration)f₂(temperature)f₃(pressure)β₀ + f₁ + f₂ + f₃Sum of contributionsInverse link function g⁻¹Transform to prediction scaleModel prediction
The diagram illustrates the additive principle. Actual feature functions and the link depend on the task and model specification.

3. Reading shape functions

A plot of fⱼ shows a feature contribution on the linear-predictor scale—not necessarily a probability or risk by itself. The horizontal axis usually shows the feature value; the vertical axis shows its estimated contribution. A zero line often serves as a reference after the chosen centering convention.If the curve rises, larger feature values in that range increase the linear predictor; if it falls, they decrease it. A flat segment indicates little change in contribution. A sharp bend may suggest a nonlinear region, but it must be checked against the number and distribution of observations.Data support and uncertainty matter. The edges of a feature range often contain few observations, so estimated shapes can be unstable there. Show a histogram or rug marks, uncertainty bands where available, and avoid claims outside the observed data range.
Shape functionAn estimated function fⱼ mapping a feature value to that feature’s contribution to the model’s additive predictor.

4. Smoothing, regularization and the trade-off

An overly flexible function may follow noise: it looks expressive on training data but changes unpredictably on new observations. Excessive smoothing can hide genuine bends or threshold-like patterns. GAMs require a balance.Spline-based GAMs commonly use a penalty on curvature or another measure of complexity. The smoothing parameter controls how strongly wiggliness is penalized. Choose it through validation or an appropriate selection criterion, without using the test set for tuning.Do not interpret every local bend as a domain law. Compare functions across resamples, time periods and subgroups; inspect data density; and account for correlated features. With strong correlation, different fits may distribute shared signal differently across feature functions.
Practical question

If a temperature curve changes sharply in a range with almost no observations, should that segment be trusted? No: weak data support makes it sensitive to smoothing and extrapolation.

5. Interactions: when separate effects are not enough

An additive GAM assumes that feature effects sum. Sometimes the effect of one feature depends on another. For example, a temperature increase may be especially informative when vibration is already high. Such patterns require interactions.An extended model can include pairwise terms: g(E[y]) = β₀ + Σ fⱼ(xⱼ) + Σ fⱼₖ(xⱼ,xₖ). The function fⱼₖ captures an additional joint contribution that cannot be represented by adding the two individual effects.Interactions increase flexibility and make explanations more demanding. A pair may require a two-dimensional surface, heat map or slices. Limit the number of interactions, justify them using domain knowledge, and check whether the data adequately cover the feature combinations.
Feature interactionA situation in which the joint contribution of two features cannot be reduced to the sum of their separate contributions.

6. EBM: an additive model trained with boosting

Explainable Boosting Machine (EBM) is a modern GAM/GA²M-family implementation. It preserves an additive structure but learns shape functions using ensembles of shallow trees and gradient boosting. A typical workflow first learns main effects for individual features, then may add selected pairwise interactions.In simplified form, EBM can be written like a GAM: g(E[y]) = β₀ + Σ fⱼ(xⱼ) + Σ fⱼₖ(xⱼ,xₖ). The difference lies in how functions are learned and controlled: binning, sequential or cyclic updates, bagging and regularization are used. Exact details depend on the library version and parameters.EBM is not simply one decision tree, nor is it an ordinary random forest. Many small trees are used to construct separate terms. The final model can still be inspected through feature functions and individual term contributions. InterpretML provides global explanations of effect shapes and local explanations of term contributions to a particular prediction.
EBM componentRoleWhat to inspect
Main effects fⱼOne function per featureShape, data range and uncertainty
Pairwise terms fⱼₖAdditional interaction between two featuresJustification, complexity and coverage
BoostingImproves functions iterativelyOverfitting and stopping settings
BaggingFits multiple bags/models to improve robustness and estimate variationVariation of functions and repeatability

7. Global and local EBM explanations

A global explanation asks: how does the model use a feature overall? Inspect its shape function, the distribution of observations and term importance. A local explanation asks a different question: which contributions produced this particular prediction?In an additive model, local contributions are summed. For one pump, the model may show that high vibration raises the risk score, normal pressure lowers it, and temperature adds a small positive contribution. This explains the model’s arithmetic; it does not prove that these variables causally affect failure.Interactions can change the local contribution of a feature pair. Therefore, a standalone fⱼ plot is not a complete description of xⱼ in every context when fⱼₖ terms are present. Also consider the link function: the sum usually lives on the linear-predictor scale, and a probability is obtained after the inverse transformation.
Global explanationA representation of model patterns and structure across the dataset.
Local explanationA decomposition of one prediction into feature and interaction contributions for an individual case.

8. Practical protocol: build and validate a GAM/EBM

Consider ranking industrial pumps by their risk of failure in the next seven days. Available data include vibration, temperature, pressure, operating hours and maintenance history. Compare logistic regression, a GAM and an EBM while preventing future-information leakage.
  1. Define the prediction time and target window. Exclude features recorded after failure or maintenance.
  2. Split by time. Use train, validation and test sets. Tune smoothing, interaction count and stopping without access to the test set.
  3. Fit a simple baseline. Logistic regression provides a reference point.
  4. Fit a GAM. Choose shape functions and smoothing; inspect plots and regions with weak support.
  5. Fit an EBM. Start with main effects, then compare no-interaction and a small number of justified pairwise terms.
  6. Compare performance and calibration. Use metrics aligned with false-alarm and missed-failure costs; do not rely on accuracy alone.
  7. Audit explanations. Inspect global functions, local contributions, uncertainty, temporal stability and subgroup behavior.
  8. Document boundaries. Record data scope, limitations, library version, parameters and cases requiring expert review.
There is no universal winner. A GAM may be preferable when smooth, domain-controlled shapes are important; an EBM may be useful when flexible learned functions and limited interactions are desired. The choice depends on data, audit needs and error costs.
CriterionGAMEBM
Effect shapeOften smooth functions such as splinesFunctions learned through boosting over bins/trees
InteractionsAdded explicitly through the model specificationMay be detected automatically or specified manually
ControlsBasis choice and smoothing penaltyBinning, interaction count, regularization, bagging and stopping
Interpretation risksComplex shapes and correlated featuresToo many terms, interactions and fine bins

9. Limitations and takeaways

GAMs and EBMs make nonlinear models more inspectable, but they do not turn statistical association into causal explanation. Plots may be unstable with sparse data, correlated features, drift or a poor specification. A local sum of contributions explains the model calculation, not necessarily the real-world mechanism.Interactions increase expressiveness and complexity at the same time. With many features and pairs, a global overview may no longer be compact. Complexity control, repeated checks, an independent test set and domain-expert review remain important.In summary: a GAM represents nonlinearity as a sum of feature functions. An EBM uses a related additive structure and learns it with boosting, bagging and, when appropriate, pairwise interactions. Both support global shape inspection and local contribution analysis—provided these explanations are validated against data and the task context.
Key question

Can we explain which functions and interactions formed a prediction, show where data are insufficient, and verify that performance holds on new observations?

Next learning step

Module 6.2 is complete. The curriculum now moves to the next Track A theme; use lesson navigation and the knowledge map to continue.

Open knowledge map ↗

References and further reading

  1. Hastie & Tibshirani (1986), Generalized Additive Models — The foundational article introducing generalized additive models.
  2. InterpretML: Explainable Boosting Machine — Describes EBM’s additive structure, main effects, interactions, and global/local explanations.
  3. InterpretML: ExplainableBoostingClassifier API — Training parameters, bagging, binning, smoothing, interactions and controls.
  4. Lou et al. (2013), Accurate Intelligible Models with Pairwise Interactions — Research foundation for GA²M models with pairwise interactions.

Lesson glossary

01Generalized Additive Model (GAM)GAM

A model whose predictor is a sum of feature-specific functions.

02Shape functionShape function

A function defining one feature’s contribution to an additive predictor.

03Link functionLink function

A function connecting the target expectation to the linear predictor.

04SmoothingSmoothing

A method for limiting excessive variation in an estimated function.

05Feature interactionFeature interaction

An additional joint effect of a pair of features.

06Explainable Boosting Machine (EBM)EBM

An additive model that learns shape functions with boosting and can include constrained interactions.

Knowledge check

Choose one answer for each question and check it. Feedback explains the key idea.

1. What does fⱼ(xⱼ) represent in a GAM?

2. What does a shape-function plot show?

3. Why add an interaction fⱼₖ(xⱼ,xₖ) to a GAM?

4. What distinguishes EBM from an ordinary linear model?

5. What must be checked before using a GAM/EBM?