Skip to content
BIASED

Features and training–serving skew

Block 1 of 6~3 min

Identify the feature and fitted state

At training time, a query can see a corrected feature value that did not exist when the original prediction was made. The row carries an old event timestamp, so a join that filters only by event time accepts it. The model is then evaluated on a better-informed world than the one it will encounter online.

The preview service gives us a small way to inspect this error. Its feature records below are independently authored; no learner data, churn dataset or production model is used. We will compare three joins and count changed decisions without claiming a measured model-accuracy improvement.

Share a feature definition and identify its state

Two pieces of code can both be called contrast while computing different quantities. One subtracts the minimum before scaling, another divides the raw value by its maximum. Both return numbers in the expected range and pass a basic schema check. A model trained on one definition has no reason to interpret the other correctly.

Keep the transformation definition and its fitted state together. A normalization function without its training mean is not the complete feature. A categorical encoder without its vocabulary cannot assign the same meaning to a column. Version the state that changes interpretation, not merely the function name.

A shared implementation reduces one source of divergence, but it does not make the two paths identical by itself. The same code applied to differently timed, filtered or authorized inputs can produce different values. Testing feature equality must therefore identify the inputs as well as the code.

Training–serving skew has several routes

Here, skew means a relevant mismatch between the features represented in training/evaluation and those available to the serving computation. Martin Zinkevich's Rules of Machine Learning discusses discrepancies in processing, changing data and feedback, and recommends observing the actual served features. Our case isolates timing while keeping the transformation simple.

A model can also lose quality because the population changed even when the two paths agree perfectly. Conversely, the two paths can disagree before any outcome labels arrive. Keep feature-consistency observations separate from estimates of predictive quality. Both matter, but they answer different questions.

Answers are saved on the server and tied to this browser until you sign in.

Go deeper — optional

Code and labs do not count toward the main percentage or the certificate.

  • Reconstruct available historical featuresoptional

    Five invented rows have distinct event and availability clocks. The selector assumes their meanings are correct and rejects conflicting eligible clock keys. No feature-store service or real accuracy measurement is involved.

    ~20 min · easier on a computer · The corresponding lesson and basic Python functions.

    Self-check in the notebook — not part of mastery or the certificate.