How To Normalize Data In Python With Scikit Learn

Next Story

How To Standardize Data In Python With Scikit Learn

Normalization

Sometimes when you are working with datasets, you will need to preprocess them for your machine learning models.

One form of preprocessing is called normalization.

It basically takes your dataset and changes the values to between 0 and 1. The smallest value becomes the 0 value and the largest value becomes 1. All other values fit in between 0 and 1.

Check out the following code snippet to check out how to use normalization on the iris dataset in sklearn.



# import necessary modules
from sklearn.datasets import load_iris
from sklearn import preprocessing

# access iris data set from sklearn datasets
iris = load_iris()

# separate data to X and y for features and targets
X = iris.data
y = iris.target

# print out normalized version of features dataset X
print(preprocessing.normalize(X))

So go ahead and try this snippet out and let me know what you think of it 🙂

https://www.googletagmanager.com/gtag/js?id=UA-63695651-4