3
$\begingroup$

Setup: I have a couple of binary classification models based on Logistic Regression and Gradient Boosted Trees. Currently I train the model offline and use it to predict the class of incoming data.

Problem: One of my features is order_count i.e. number of purchases made by the user. So if the order_count of a user changes (i.e. he/she purchases new products) it will not be reflected in my classification model until I retrain it. There are 1000s of such dynamically changing features.

Current solution: One option is to retrain the model say every day or every week with the updated dataset.

Question: Is there any alternative to this method of retraining at regular intervals? Is there a way to update the model with the modified training samples in real time? For example, the moment a user purchases a new product, the model should re-train itself based on this updated data in real time. Or is there some completely different approach that people use in such a situation?

$\endgroup$
4
  • $\begingroup$ You may want to look into online learning. $\endgroup$ Commented Feb 2, 2015 at 7:23
  • $\begingroup$ Hey Marc. I have taken a look at online learning. In fact I'm using SGD for Logistic Regression. My problem lies in the fact that the training samples seen by the model to compute the feature weights keep changing and I want the model to sort of 'forget' the old sample and use the new 'updated' sample instead $\endgroup$
    – Mihir Kale
    Commented Feb 2, 2015 at 10:46
  • $\begingroup$ You can mimick that effect by weighting new observations higher than usual in the update step. $\endgroup$ Commented Feb 2, 2015 at 11:51
  • $\begingroup$ That sounds interesting. Can you point me to someplace that will guide me on how to go about doing the weighting? What formula to use to do the wighting (linear/exponential). Plus I can't just keep increasing the weights right....after a while they'll become unnecessarily huge. Thanks @MarcClaesen! $\endgroup$
    – Mihir Kale
    Commented Feb 3, 2015 at 12:27

1 Answer 1

5
$\begingroup$

Instead of retraining the model, it is best to use a procedure such as stochastic gradient descent (SGD), in which the true gradient $Q(\mathbf{w})$ is approximated by the gradient at a single new sample and the intermediate solution $\mathbf{w}$ is updated accordingly: $$\mathbf{w} \leftarrow \mathbf{w} - \alpha \nabla Q_i(\mathbf{w}),$$ where $\alpha$ is the step size aka learning rate. A large step size implies a higher weight to the gradient of the new sample $Q_i(\mathbf{w})$. Usually, the step size remains fixed and is treated as a hyperparameter.

Increasing the step size will automatically emphasize new instances in an online setting. You can think of this as overfitting the new data to some extent. To be clear: you do not have to increase the step size over iterations, just use a larger value of $\alpha$ than you typically would in a standard context.

You can do the same idea in a minibatch sense, instead of for a single example

$\endgroup$

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.