Feature engineering and preprocessing · insight-0120
Guard ratio features against zero and tiny denominators
- Evidence type
- practitioner heuristic
- Difficulty
- easy
- Roles
- Data scientist, Data analyst, ML engineer
- Industries
- aviation, e-commerce
Summary: situation, action, reason, boundary
Situation
You build ratios such as revenue per seat, cancellations per booking or spend per visit.
Action
Define the ratio's behaviour for small denominators explicitly: add a floor, smooth with a prior, set to missing below a minimum count, and keep the denominator as its own feature.
Reason
A ratio from three bookings is far noisier than one from three hundred; keeping the denominator lets the model learn how much to trust it.
Boundary
Rates, per-unit metrics and conversion features in any tabular model.
Symptom or risk
Rows with near-zero denominators produce enormous or infinite values that dominate scaling, losses and plots.
Exceptions
Physically bounded ratios with large denominators, such as load factor on fixed capacity, are usually safe.
Trade-offs
Floors and smoothing introduce bias for small groups in exchange for stability.
Pitfalls
Computing a ratio from a numerator measured after the prediction time, such as final bookings on the day of departure.