1
$\begingroup$

I'm interested in incremental (online) learning for my logistic regression model trained with SGDClassifier. Basically updating the model as more labeled data comes in. I know I can use partial_fit() for this. The following seems to be a common example on StackOverflow:

clf = linear_model.SGDClassifier()
x1 = some_new_data
y1 = the_labels
clf.partial_fit(x1,y1)
x2 = some_newer_data
y2 = the_labels
clf.partial_fit(x2,y2)

The problem is, partial_fit() performs just one step of gradient descent:

Internally, this method uses max_iter = 1. Therefore, it is not guaranteed that a minimum of the cost function is reached after calling it once. Matters such as objective convergence and early stopping should be handled by the user.

Would one step be enough? How do I know if I don't need to make more steps than just one per each new labeled datapoint / minibatch that comes in?

$\endgroup$
1
$\begingroup$

Monitor the metrics that you are attempting to optimize, and compute the change in those metrics after each epoch. Once those metrics stop improving according to certain criteria, then you can stop gradient descent. See this article for a way to keep track of the metric improvements.

|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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