Recipe: How to rescale features in Python?

How to rescale features in Python?

This recipe helps you rescale features in Python
In [ ]:
## How to rescale features in Python 
def Kickstarter_Example_39():
    print(format('How to rescale features in Python', '*^82'))
    import warnings

    # load libraries
    from sklearn import preprocessing
    import numpy as np

    # Create feature
    x = np.array([[-500.5],

    # Rescale Feature Using Min-Max
    # Create scaler
    minmax_scale = preprocessing.MinMaxScaler(feature_range=(0, 1))

    # Scale feature
    x_scale = minmax_scale.fit_transform(x)

    # Show feature
    print(); print(x)
    print(); print(x_scale)


Stuck at work?
Can't find the recipe you are looking for. Let us know and we will find an expert to create the recipe for you. Click here
Companies using this Recipe
1 developer from CGI
1 developer from LTI
1 developer from Vodafone
1 developer from Altimetrik
1 developer from HvH
1 developer from Microsoft
1 developer from Wildstorm
1 developer from ANAC
1 developer from Infosys
1 developer from MudraCircle