8
$\begingroup$

Introduction
When training a model a "sample" usually refers to the data used to fit the model, so...

Sample: Data used for training model
Out-of-sample: Data not used for training model
Out-of-time: Data not used for training model that is later than data used to train the model

Sometimes regulation says you must perform "out-of-sample" and "out-of-time" validation of your model. But it is not clear what is ment as "out-of-time" is already "out-of-sample". I think "out-of-sample" could be interpreted as validation on customers that were not part of the training "sample".

Interpretation 1
Here the interpretation is that one makes two independent validation runs:

  1. Validation on "out-of-sample" data that is "in-time"
  2. Validation on "out-of-time" data that is also "out-of-sample"

enter image description here

The big flaw as I see it here is that the "out-of-sample" validation will be "in-time", thus the performance metrics will likely be very inflated. An example would be if the "in-time" period was during covid, then you would get "out-of-sample" validation results indicating that you are doing great on these unseen customers, while in reality the model would perform horribly on the unseen customers in a production environment (which is out-of-time).

Interpretation 2
Here the interpretation is that it makes little sense to do any reporting of numbers from the "in-time" "out-of-sample" data, as the numbers don't really say anything about real world performance. Instead all validation numbers reported to the regulators are out-of-time.

  1. Validation on "out-of-sample" data that is "out-of-time" alone. This is the MOST conservative estimate of real world performance. It is also the best metric for generalizability. Here "out-of-sample" refers to customers, who have not even been in the training sample "in-time".
  2. Validation on ALL "out-of-time" data, as this is the best estimate of performance in the immediate future, as a customer base is usually quite stable in the immediate future (e.g. the next 2-3 years).

enter image description here

With this interpretation that numbers you report are the most conservative, likely reflect real-world performance the best and reflect generalizability (e.g. to unseen customers).

Question Which interpretation would you use? Do you think both interpretations are equally valid?

$\endgroup$
9
  • 5
    $\begingroup$ In the forecasting community, we usually care about "out of time" only. What do you mean by "out of sample" as opposed to "out of time"? $\endgroup$ Commented Oct 23 at 7:50
  • 1
    $\begingroup$ In a project we did both, but out of + time out of training sample was the most important one in the end $\endgroup$
    – Ggjj11
    Commented Oct 23 at 8:11
  • $\begingroup$ The regulation says: "establish a rigorous statistical process including both out-of-time and out-of-sample performance tests for validating the model" $\endgroup$ Commented Oct 23 at 8:23
  • $\begingroup$ @StephanKolassa In "interpretation 2" out-of-sample means samples that are out-of-time, and customer-ids never seen by the model. Else I could just make a model that used customer-id as a feature, and it would perform ok out-of-time in the immediate future. $\endgroup$ Commented Oct 23 at 9:01
  • 2
    $\begingroup$ Not much to add to the great answer by @stephan-kolassa , but I really like this blog post on validation (& test) sets. Basic message: the way you split should match what in reality is your prediction task (i.e. what is yoru existing data & for what do you predict?). E.g. if you predict for some existing customers + new customers, then strictly splitting by customers for your validation misses out on the bit where you have some past interactions with existing customers, but you still need to make sure to split interactions in time. $\endgroup$
    – Björn
    Commented Nov 14 at 8:59

1 Answer 1

13
$\begingroup$

For precisely the reasons you outline, validation and testing data should always respect the time ordering and not "learn from the future", because real world performance (I like to call this "in production") is ultimately what we care about. I would argue that this may not only apply to cases commonly called "forecasting", but also to "classification" tasks with time dimensions: if you build a model for credit scoring or churn prediction, the time dynamics may be so strong that you may be well advised to include the time dimension in your modeling and only use out-of-time test/validation sets.

Now, this is to a degree opinion-based.

However, this is in my opinion the absolute consensus in the forecasting community (less so among classifiers), which I have been involved with for a number of years, so yes, I do believe I know what I am talking about. As an Associate Editor and frequent reviewer at the International Journal of Forecasting, any submission that "learns from the future" will get a major revision at the very least, or a reject usually, because the authors apparently did not understand the very first thing about forecasting. Finally, all serious forecasting resources will be very clear on this point.

$\endgroup$
8
  • 1
    $\begingroup$ Thanks for the clarification. Our model is a classification model, but I would still think that e.g. when doing feature selection and hyper parameter tuning, one would want an out-of-time validation set to ensure that one selects time-robust features and parameters. What do you think about that? $\endgroup$ Commented Oct 23 at 11:03
  • 2
    $\begingroup$ That is exactly what I think makes the most sense, because this way you are more realistic about data and model drift. Of course, that means you are at the mercy of any specific things that happened during your training, testing and validation periods... but I would still say that any other way is essentially lying to yourself. $\endgroup$ Commented Oct 23 at 11:21
  • 1
    $\begingroup$ The reason for the question is that the "expert" consultants that have been hired in strongly recommend doing "out-of-sample" validation "in-time". It is against everything I have learned in my 15 years in data science and statistics. It is nice with a confirmation that this "in-time" validation is a bad and misleading approach. But I guess it is a great way to inflate one's performance metrics! $\endgroup$ Commented Oct 23 at 11:33
  • 2
    $\begingroup$ (1) Even consultants can be wrong, and I am sure they would say the same about people giving advice here on CV, absolutely fair. (2) Of course you will need to tailor your analysis pipeline to your specific situation, data, subsequent use of the model etc. (3) I am not quite sure what regulation you are referring to - is this something official, legal or governmental, or a list of requirements drawn up by someone buying a service? $\endgroup$ Commented Oct 23 at 13:43
  • 5
    $\begingroup$ Thanks, that does make sense. Unfortunately, once you have a predictor that appears to improve your model (whether this is noise or not), humans are very prone to find "explanations". Perhaps people who apply for a loan on Tuesdays are worse risks, because they are more likely not to be holding down a regular 9-5 job (because people with such jobs are more likely to apply on the weekend)... $\endgroup$ Commented Oct 24 at 7:32

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.