Save MinMaxScaler model in sklearn

前端 未结 5 1515
青春惊慌失措
青春惊慌失措 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:36

    The best way to do this is to create an ML pipeline like the following:

    from sklearn.pipeline import make_pipeline
    from sklearn.preprocessing import MinMaxScaler
    from sklearn.externals import joblib
    
    
    pipeline = make_pipeline(MinMaxScaler(),YOUR_ML_MODEL() )
    
    model = pipeline.fit(X_train, y_train)
    

    Now you can save it to a file:

    joblib.dump(model, 'filename.mod') 
    

    Later you can load it like this:

    model = joblib.load('filename.mod')
    

提交回复
热议问题