Save MinMaxScaler model in sklearn

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

    You can use pickle, to save the scaler:

    import pickle
    scalerfile = 'scaler.sav'
    pickle.dump(scaler, open(scalerfile, 'wb'))
    

    Load it back:

    import pickle
    scalerfile = 'scaler.sav'
    scaler = pickle.load(open(scalerfile, 'rb'))
    test_scaled_set = scaler.transform(test_set)
    

提交回复
热议问题