Google News
logo
Machine Learning - Interview Questions
What is Rescaling of data and how is it done?
In real-world scenarios, the attributes present in data will be in a varying pattern. So, rescaling of the characteristics to a common scale gives benefit to algorithms to process the data efficiently.
 
We can rescale the data using Scikit-learn. The code for rescaling the data using MinMaxScaler is as follows:
 
#Rescaling data
import pandas
import scipy
import numpy
from sklearn.preprocessing import MinMaxScaler
names = ['Ramu', 'Ramana', 'Mounika', 'Sathya', 'raj', 'mani', 'samu', 'venu', 'sam']
Dataframe = pandas.read_csv(url, names=names)
Array = dataframe.values
# Splitting the array into input and output
X = array[:,0:8]
Y = array[:,8]
Scaler = MinMaxScaler(feature_range=(0, 1))
rescaledX = scaler.fit_transform(X)
# Summarizing the modified data
numpy.set_printoptions(precision=3)
print(rescaledX[0:5,:])

 

Advertisement