1

I'm working on a machine learning classification task in which I have trained many models with different algorithms in scikit-learn and Random Forest Classifier performed the best. Now I want to train the model further with new examples but if I train the same model by calling the fit method on new examples then it will start training the model from beginning by erasing the old parameters. So, how can I train the trained model by training it with new examples in scikit-learn?

I got some idea by reading online to pickle and unpickle the model but how would it help I don't know.

2
  • Maybe something proposed here will help datascience.stackexchange.com/questions/28512/… Commented Apr 18, 2019 at 19:54
  • I have checked that page before asking my question here and the answers to that question are not helpful. Commented Apr 19, 2019 at 3:13

3 Answers 3

1

You should use incremental learning and estimators implementing the partial_fit API.

Sign up to request clarification or add additional context in comments.

Comments

0

RandomForrestClassifier has a flag warm_start. Note that this will not give the same results as if you train on both sets at once.

1 Comment

To train the model on new data I have to create an another model (object of the RandomForestClassifier class) then if I set it to warm_start=True then how can it take parameters from an another model?
0

Append the new data to your existing dataset, and train over the whole thing. Might want to reserve some of the new data for your testset.

4 Comments

That is not my goal, why would I train my whole data set again and again!
Because it is the most straightforward solution. And works the same way no matter how many extra examples are added.
@JonNordby Is it possible to re-train the trained model with new data? or update the old weights? or re-fit the saved model on new data only?
There are two related mechanisms, warm_start and partial_fit. But unless actually training from scratch is problematic, I do not recommend them. datascience.stackexchange.com/a/68756/54096

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.