Rescaling data to its initial state after applying MinMax scaling

XbiTake report abuse

To scale my data I used a MinMaxScaler provided in the sklearn package. But I wonder if there any way to "rescale" it back to its original state?

Answers

KoloNuto report abuse

You can use the inverse_transform method from the sklearn library. Let's look at the example.

Suppose you have the data cols = ['One', 'Two'] data = pd.DataFrame(np.array([[2,3],[1.02,1.2],[0.5,0.3]]),columns=cols)

So that we have the following output: https://prnt.sc/p3y38w

After applying the min-max scaling we obtain the next result (https://prnt.sc/p3y3he) scaler = preprocessing.MinMaxScaler(featurerange = (0,1)) scaleddata = scaler.fit_transform(data[cols])

After applying inversetransform() method we get our data at its initial range back (https://prnt.sc/p3y48c) scaler.inversetransform(scaled_data)

XbiTake report abuse

Brilliant, that's it! Thank you!

Add Answer

Need support?

Just drop us an email to ... Show more