Assign more importance to recent records during training

My goal is to build a classification model in order to predict if a customer will buy a product or not (binary classification).

Since in the last months (let's say 3-4) I know that the advertising of the company is changed a bit, I want to put more emphasis on the newer records.

I know that it is possible to specify the sample_weights parameter in most of the classification algorithms, but I don't know how to properly build these weights.

Basically, I have the date in which the customers have (or have not) bought the product, but I want to understand if there is a specific way to build the weights using this information.

In addition, I would also know if someone knows some references or applications for this application (time-related sampling weights).

• Have you heard about adversarial validation? kaggle.com/tunguz/elo-adversarial-validation It basically implies training a model that helps you classify between training and testing samples. I think you could apply that to your problem, and use the predictions of the adversarial model that predicts last months vs older data as the weights of your samples Jul 31, 2020 at 10:32
• Not sure what is the best solution here, nonetheless, a thing for you to have in mind is that you can also oversample the more recent instances or inversely downsample the older ones, you get the idea. For some algorithms, this works better than setting weights, or maybe it's not even possible. Jul 31, 2020 at 19:58

If you want to define weights for your datapoints, you can just calculate them with a simple formula that has the right shape. Let your weights be a function of the age of the datapoint and choose wether you want to model their relative imortance with a linear or an exponential function.

It could be as simple as:

$$w(t) = 2^{-0.1t}$$

Which would give the relevance of your data a half-life time of ten days.

New contributor
Anne is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

One option is incremental training. Update the model weights as more recent data is available. This automatically assigns more importance to recent records.

Incremental training works well within the Bayesian framework where historical data is the prior and more recent data updates the prior.