Recipe: How to standardise features in Python?
DATA MUNGING DATA NORMALIZATION

How to standardise features in Python?

This recipe helps you standardise features in Python
In [1]:
## How to standardise features in Python 
def Kickstarter_Example_40():
    print()
    print(format('How to standardise features in Python', '*^82'))
    import warnings
    warnings.filterwarnings("ignore")

    # Load libraries
    from sklearn import preprocessing
    import numpy as np

    # Create feature
    x = np.array([[-500.5],
                  [-100.1],
                  [0],
                  [100.1],
                  [900.9]])

    # Standardize Feature
    # Create scaler
    scaler = preprocessing.StandardScaler()

    # Transform the feature
    standardized_x = scaler.fit_transform(x)

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

Kickstarter_Example_40()
**********************How to standardise features in Python***********************

[[-500.5]
 [-100.1]
 [   0. ]
 [ 100.1]
 [ 900.9]]

[[-1.26687088]
 [-0.39316683]
 [-0.17474081]
 [ 0.0436852 ]
 [ 1.79109332]]


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 Deepera
1 developer from Infosys
1 developer from Tata Consultancy Services
1 developer from Altimetrik
1 developer from HSBC
1 developer from KPMG
1 developer from Trux
1 developer from ANAC
1 developer from HvH
1 developer from LTI