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?
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