Answers for "use of minmaxscaler in python"

0

Python MinMaxScaler()

from sklearn.preprocessing import MinMaxScaler

#Normal minmaxscaler function to standarise data.
data = [[-1, 2], [-0.5, 6], [0, 10], [1, 18]]
scaler = MinMaxScaler()
scaler.fit(data)    

#get data for Max and Min from scaler functions, 
#best to store it in a dictionary and use it later make data normal again
print(scaler.transform([[2, 2]]))
Out>>> [[ 1.5  0. ]]

# Inverse transform the the 0-1 dataframe.
print(scaler.inverse_transform([[ 1.5  0. ]]))
Out>>> [[ 2.0  2.0]]
Posted by: Guest on July-01-2021

Python Answers by Framework

Browse Popular Code Answers by Language