Train/test split on time-based data with lagged features I am working with data on bank transactions, and am using RFM (recency/frequency/monetary value) features like days since last transaction, number of transactions last n days, average value of transactions last n days.
I am planning on splitting the data based on time. Let's say I have a year's worth of data, and I'm holding out the last three months for my test set.
Should I compute the RFM features before or after the train/test split? My hunch is that it should be after to prevent data leakage, but that means that I'll essentially have to completely exclude data that is n days. In other words, if my window is 30 days, in order to have accurate RFM data in the test set, I would need to discard the first month from the test set. Is that right?
The model once deployed would likely be updated weekly with the full range of data available.

There is no data leakage if you construct the test samples' features using past data. The test data doesn't leak into the training, so it's not a data leakage.
