0 votes
in Machine Learning by

How to Standardize data in machine learning?

1 Answer

0 votes
by
Standardization is the method that is used for rescaling data attributes. The attributes would likely have a value of mean as 0 and the value of standard deviation as 1. The main objective of standardization is to prompt the mean and standard deviation for the attributes.

We can standardize the data using Scikit-learn. The code for standardizing the data using StandardScaler is as follows:

# Python code to Standardize data (0 mean, 1 stdev)

from sklearn.preprocessing import StandardScaler

import pandas

import numpy

names = ['Abhi', 'Piyush', 'Pranay', 'Sourav', 'Sid', 'Mike', 'pedi', 'Jack', 'Tim']

dataframe = pandas.read_csv(url, names=names)

array = dataframe.values

# Separate the array into input and output components

X = array[:,0:8]

Y = array[:,8]

scaler = StandardScaler().fit(X)

rescaledX = scaler.transform(X)

# Summarize the transformed data

numpy.set_printoptions(precision=3)

print(rescaledX[0:5,:])

Related questions

0 votes
asked Nov 29, 2019 in Machine Learning by SakshiSharma
+1 vote
asked Mar 10, 2021 in Machine Learning by SakshiSharma
...