Learning outcomes
After this lesson, you will be able to:
- Explain why a linear relationship may be insufficient to represent a real process.
- Distinguish common ways to represent nonlinearity: threshold rules, trees, rule sets, and feature transformations.
- Read a shallow tree and explain a prediction through its decision path.
- Assess how depth, rule count, and interactions affect model clarity and stability.
- Choose a testable nonlinear model in light of performance, constraints, and application context.
1. When a linear relationship is not enough
Imagine estimating industrial pump failure risk from vibration. Within the normal range, a small increase in vibration may barely change the risk. Beyond a threshold, risk may rise much faster. A straight line with one constant slope cannot represent this pattern well.
Nonlinearity occurs when a feature's effect changes across ranges, has a threshold or saturation pattern, or depends on another feature. This does not make the relationship causal: the model describes statistical associations in the data.
2. Different representations of nonlinearity
The representation determines what a person can inspect. Some approaches retain explicit thresholds and rules; others add flexibility through feature transformations.
| Representation | How it captures nonlinearity | What can be inspected | Limitation |
|---|---|---|---|
| Shallow tree | Sequential threshold splits | Path from root to leaf | Stepwise boundaries; possible instability |
| Rule set | If–then conditions | Conditions, order, and exceptions | Many or overlapping rules are hard to review |
| Transformed features | Squares, logarithms, piecewise-linear bases | Coefficients and contributions of constructed features | Interpretation depends on the chosen basis |
| Constrained model | Nonlinear form under constraints such as monotonicity | Whether specified behaviour is respected | Constraints need a domain justification |
3. Decision trees: thresholds instead of one line
A tree divides the feature space into regions. Each region ends in a leaf that provides a prediction. A tree can therefore represent threshold effects and combinations of conditions without relying on one global slope.
For example, a model may first check vibration and, if vibration is elevated, check temperature. For an individual pump, the local explanation is the path from root to leaf: “vibration is above the threshold; temperature is above its threshold; predicted risk is high.”
A deep tree can represent complex combinations, but a long path becomes difficult to inspect. Limits on depth, minimum leaf size, and leaf count help control complexity, although they do not guarantee stability.
4. Reading a nonlinear shape
The diagram shows an illustrative relationship between vibration and estimated risk. The increase is modest before a threshold and steeper afterwards. This is a shape illustration, not measured evidence. In a real task, the shape must be checked against data and domain knowledge.
Feature transformations can add curvature or segments with different slopes. But the more basis functions and interactions we add, the more carefully we must explain what each component means.
5. Rules and feature interactions
A rule combines conditions into an inspectable statement. For example: “if vibration is above its threshold and temperature is elevated, assign the pump to the higher-risk group.” Such rules are useful when specialists need to see exactly when a condition fires.
A rule is not reliable merely because it is written in plain language. We need to know how many observations support it, how often it is wrong, whether it overlaps with other rules, and what happens to observations that match none of the conditions.
| Rule check | Why it matters |
|---|---|
| Support | How many observations satisfy the rule |
| Precision | Share of correct positive predictions among rule activations |
| Coverage | Share of observations covered by a rule or rule set |
| Conflicts and order | Whether rules overlap or produce incompatible conclusions |
An interaction means that the effect of one feature depends on another. For example, high temperature may be especially informative when vibration is also high. If interactions matter, the model must represent them and the analyst must check that the result is not an artefact of rare combinations.
6. Practical analysis: from data to an inspectable model
Suppose we need to rank pumps by their risk of failure in the next seven days. Available features include vibration, temperature, pressure, operating time, and maintenance history. The goal is a useful prediction whose basis can still be reviewed.
- Define the task and prediction time. Fix the seven-day horizon and exclude features only known after failure.
- Build a baseline. Start with logistic regression or a simple linear model for comparison.
- Add controlled nonlinearity. Compare a shallow tree with a model using pre-defined feature transformations.
- Constrain complexity. Record maximum depth, leaf count, rule count, or permitted interactions.
- Evaluate on identical splits. Use time-based train/validation/test splits; tune only on training and validation data.
- Check stability. Compare rules and thresholds across time windows and pump subgroups.
- Document boundaries. State where the model has not been tested, which rules have little support, and when expert review is required.
Do not select a nonlinear model merely because it fits the training sample better. Any improvement should persist on independent data and justify the additional complexity.
7. Evaluating clarity and performance together
Evaluation should not collapse into one score. Use task-appropriate performance metrics and record measurable structural properties. Include people who will use or audit the model in the clarity review.
| Aspect | What to inspect | Example question |
|---|---|---|
| Predictive performance | Held-out metrics and calibration | Does performance persist in later periods? |
| Structural size | Depth, leaves, rules, interactions | Can the full logic be reviewed? |
| Stability | Changes in thresholds and rules across samples | Does a small data shift change the explanation? |
| User understanding | Tasks that require reading and applying rules | Can a specialist correctly explain the prediction? |
| Limits and safety | Subgroup errors, exceptions, out-of-range cases | Is it clear when the model should not be trusted? |
Clarity depends on the audience and task. Ten rules may be manageable for an engineering analyst but too many for an operator who must decide within seconds.
8. Limitations and common mistakes
- “A nonlinear model must be a black box.” No: thresholds, trees, and explicit rules can be inspected.
- “An understandable rule must be correct.” Clarity does not replace checks of quality, support, and stability.
- “The smaller the tree, the better.” An overly simple structure may miss important patterns; the balance needs justification.
- “A model-found threshold is physically meaningful.” It may reflect the sample, measurement process, or training procedure.
- “A monotonic constraint is always right.” Use it only with a domain rationale and check the relevant ranges.
- “High rule precision proves causality.” A rule describes a predictive association, not a causal mechanism.
9. Lesson summary
- Nonlinearity can represent thresholds, saturation, curvature, and feature interactions.
- Trees and rules express nonlinearity through explicit conditions; feature transformations express it through model components.
- Greater depth, rule count, and interaction count increase flexibility but may reduce readability and stability.
- Check not only predictive metrics but also structural stability, rule support, and clarity for the intended audience.
- An interpretable structure does not guarantee correctness, causality, or safe deployment.
What comes next
The next lesson introduces GAMs and EBM: models that represent nonlinear relationships through feature-specific functions and make their contributions available for inspection.
Open knowledge map ↗Sources and further reading
- scikit-learn: Decision Trees — Documentation on decision trees, complexity parameters, and limitations.
- Interpretable Machine Learning: Decision Rules — An overview of decision rules and ways to evaluate them.
- scikit-learn: Polynomial and spline features — Feature transformations for representing nonlinear relationships.
- Molnar et al.: Interpretable Machine Learning — A Brief History, State-of-the-Art and Challenges — A review of approaches and challenges in interpretable machine learning.
Lesson glossary
A relationship that one linear function cannot adequately represent across the full range.
A condition that divides feature values at a specified threshold.
The sequence of conditions followed from a tree root to a leaf.
The number or share of observations satisfying a rule.
A situation in which the effect of one feature depends on another.
The extent to which main rules and thresholds persist under reasonable data changes.
Self-check
Choose one answer for each question and select “Check answer”. The feedback explains the key principle.