Pages

Friday 22 March 2019

Implement Normalization in Python using Scikit Learn Library

Normalization and Standardization are Feature Scaling techniques in Machine Learning. Normalization converts the values into the range of 0 and 1. Today, we will see how is normalization implemented in Python using Scikit Learn library?

We will use California Housing dataset and normalize the "Total Bedroom" feature. You can download this dataset from here and my Jupyter notebook from here

Generally, we should normalize all the numeric features of the dataset but for the sake of simplicity, I will do it only for one feature.

Step 1: Load the required libraries like pandas, numpy and sklearn

import pandas as pd
import numpy as np
from sklearn.preprocessing import normalize

Step 2: Load the dataset

dataframe = pd.read_csv('california_housing_train.csv')

Step 3: Normalize the feature

x_array = np.array(dataframe['total_bedrooms'])
x_normalized = normalize([x_array])
x_array
x_normalized

Related
Normalization vs Standardization
Why are Normalization and Standardization required?

No comments:

Post a Comment

About the Author

I have more than 10 years of experience in IT industry. Linkedin Profile

I am currently messing up with neural networks in deep learning. I am learning Python, TensorFlow and Keras.

Author: I am an author of a book on deep learning.

Quiz: I run an online quiz on machine learning and deep learning.