Sklearn's MinMaxScaler only returns zeros

前端 未结 4 1491
情话喂你
情话喂你 2021-01-12 20:12

I am trying to scale a some number to a range of 0 - 1 using preprocessing from sklearn. Thats what i did:

data = [44.645, 44.055,          


        
4条回答
  •  抹茶落季
    2021-01-12 21:08

    This is because data is a int32 or int64 and the MinMaxScaler needs a float. Try this:

    import numpy as np
    data = [44.645, 44.055, 44.54, 44.04, 43.975, 43.49, 42.04, 42.6, 42.46, 41.405]
    min_max_scaler = preprocessing.MinMaxScaler(feature_range=(0, 1))
    data_scaled = min_max_scaler.fit_transform([np.float32(data)])
    print data_scaled
    

提交回复
热议问题