Update: sklearn.externals.joblib
is deprecated. Install and use the pure joblib
instead. Please see Engineero’s answer below, which is otherwise identical to mine.
Original answer
Even better than pickle
(which creates much larger files than this method), you can use sklearn
‘s built-in tool:
from sklearn.externals import joblib
scaler_filename = "scaler.save"
joblib.dump(scaler, scaler_filename)
# And now to load...
scaler = joblib.load(scaler_filename)