krishnaik06 / mlproject

437 stars 559 forks source link

Saved model.pkl file is not trained #3

Open svkadhikary opened 1 year ago

svkadhikary commented 1 year ago

Sir, I want to point out one significant point about the saved model.pkl file. In the utils.py file, we never returned the best model object itself, just the score. https://github.com/krishnaik06/mlproject/blob/6d24fc7626f87b16734e5334ca47fccc67a97300/src/utils.py#L50 And then in model_trainer.py we sort the best max score and then initialize a totally new model based on the name of the highest score model. And in the save_object we are actually saving the newly initialized model which is untrained. https://github.com/krishnaik06/mlproject/blob/6d24fc7626f87b16734e5334ca47fccc67a97300/src/components/model_trainer.py#L98 What's strange is how it gave a prediction. Mine didn't and I had to edit the code. https://github.com/svkadhikary/student_perfomance/blob/45ba9818eb3ab7fb681da7c70d425ed0c70fc0a0/src/utils.py#L66 https://github.com/svkadhikary/student_perfomance/blob/45ba9818eb3ab7fb681da7c70d425ed0c70fc0a0/src/components/model_trainer.py#L100

Swam80 commented 1 year ago

Hey,

The model is trained with the best parameters in utils.py itself. See where model.set_params(**gs.bestparams) is done. It sets the parameters to all the model objects one by one and then we do fit, which means it has trained. I hope you got your point cleared since its been two weeks now.