How to Standardize Data in Python
In this article, we will discuss standardization of data with scikit-learn.
Often when working with datasets for data science, we may need to standardize our dataset before fitting a machine learning model to it.
Standardization refers to shifting the distribution of each attribute to have a mean of zero and a standard deviation of one (unit variance)
# Standardize the data attributes for the sample dataset. # here iris dataset is used from sklearn.datasets import load_iris from sklearn import preprocessing # load the Iris dataset iris = load_iris() print(iris.data.shape) # separate the data and target attributes X = iris.data y = iris.target # standardize the data attributes standardized_X = preprocessing.scale(X)
Subscribe
Login
Please login to comment
0 Discussion