Context: I am working on a classification project. where I recommend items to customers based on their past purchase history.

Question: How will "time leakage" affect training?

Example: Let's say that I am trying to predict today's purchases for some customer. I train only on the previous history, without any knowledge of what will be purchased today. My features consist of a set of binary variables that for any given day in history could be thought of as either recommending (1) or not recommending (0) an item (essentially acting as "dumb" classifiers themselves). For example, one of these features could be whether or not an item is in the customer's top 10 list, etc.

In this case, is it acceptable to compute top 10 over all of history and based on this list create a feature that is applied to each day in history? Of course, this will cause the features from the first day in history to have knowledge of the future.

Or would having a sliding window where feature creation that can only look into the past be more appropriate?


1 Answer 1


I don't completely understand your example, but:

if you want to put your model into operation/production environment at some day ... then you should not allow 'looking into the future' at training time.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.