Save MinMaxScaler model in sklearn

前端 未结 5 1521
青春惊慌失措
青春惊慌失措 2020-12-23 13:58

I\'m using the MinMaxScaler model in sklearn to normalize the features of a model.

training_set = np.random.rand(4,4)*10
training_set

       [[         


        
5条回答
  •  天命终不由人
    2020-12-23 14:45

    So I'm actually not an expert with this but from a bit of research and a few helpful links, I think pickle and sklearn.externals.joblib are going to be your friends here.

    The package pickle lets you save models or "dump" models to a file.

    I think this link is also helpful. It talks about creating a persistence model. Something that you're going to want to try is:

    # could use: import pickle... however let's do something else
    from sklearn.externals import joblib 
    
    # this is more efficient than pickle for things like large numpy arrays
    # ... which sklearn models often have.   
    
    # then just 'dump' your file
    joblib.dump(clf, 'my_dope_model.pkl') 
    

    Here is where you can learn more about the sklearn externals.

    Let me know if that doesn't help or I'm not understanding something about your model.

    Note: sklearn.externals.joblib is deprecated. Install and use the pure joblib instead

提交回复
热议问题