I have trained a prediction model using scikit-learn, and used pickle
to save it to hard drive. The pickle
file is 58M, which is quite sizable.
To use the model, I wrote something like this:
def loadModel(pkl_fn):
with open(pkl_fn, 'r') as f:
return pickle.load(f)
if __name__ == "__main__":
import sys
feature_vals = read_features(sys.argv[1])
model = loadModel("./model.pkl")
# predict
# model.predict(feature_vals)
I am wondering about the efficiency when running the program many times in command line.
Pickle files are supposed to be fast to load, but is there any way to even speed up? Can I compile the whole thing into a binary executable?