Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(how) can you train a model twice (multiple times) in sklearn using fit.?

Example : my data doesn't fit into memory can I do :

model=my_model
for i in range(20)
       model.fit(X_i,Y_i)

This will delete the first 19 fit. and keep only the last one. How can I avoid this? Can I retrain a model saved and loaded? Thank you

like image 791
Philippe C Avatar asked Apr 18 '16 17:04

Philippe C


People also ask

What does calling Fit () multiple times on the same model do?

fit(X_train, y_train) for a second time - it'll overwrite all previously fitted coefficients, weights, intercept (bias), etc. Some estimators (having the warm_start parameter) will reuse the solutions from the previous calls to fit() as initial solution in new call when warm_start = True .

Can I call model fit multiple times?

Yes, successive calls to fit will incrementally train the model. So, yes, you can call fit multiple times.

What is the purpose of fit () method in Sklearn?

The fit() method takes the training data as arguments, which can be one array in the case of unsupervised learning, or two arrays in the case of supervised learning.

What happens when you fit a model?

Model fitting is a measure of how well a machine learning model generalizes to similar data to that on which it was trained. A model that is well-fitted produces more accurate outcomes. A model that is overfitted matches the data too closely. A model that is underfitted doesn't match closely enough.


1 Answers

Some models have a "warm_start" parameter, where it will initialise model parameters with the previous solution from fit()

See for instance SGDClassifier

like image 147
Mathias Andersen Avatar answered Sep 21 '22 17:09

Mathias Andersen