Nick
Nick

Reputation: 1934

Sklearn Joblib Dump Replace Existing .pkl files

I'm trying to persist prediction model state by saving my model with

joblib.dump(model, path)

This works fine, but if I do it twice, the second set of generated .pkl_* files don't really overwrite the old ones, so when I go to call joblib.load(path), I can't be sure it's actually loading in the correct model.

How do I make it so joblib.dump destroys the old .pkl_* files before saving new ones?

Upvotes: 7

Views: 2490

Answers (2)

Varun Kumar
Varun Kumar

Reputation: 119

You actually don't need to do the "wb" while using joblib. I was facing the similar issue; realising later that I was dumping and loading from different locations.

Upvotes: 0

simon
simon

Reputation: 2831

Instead of a path if you pass in a file opened with "wb" then it will overwrite.

Upvotes: 2

Related Questions