Question: Load the hmeq _ small.csv data set as a data frame. Standardize the data set as a new data frame. Normalize the data set as
Load the hmeqsmall.csv data set as a data frame.
Standardize the data set as a new data frame.
Normalize the data set as a new data frame.
Print the means and standard deviations of both the standardized and normalized data.
Ex: Using the first rows, found in hmeqsample.csv the output is:
The means of df are LOAN e
MORTDUE e
VALUE e
YOJ e
CLAGE e
CLNO e
DEBTINC e
dtype: float
The standard deviations of df are LOAN
MORTDUE
VALUE
YOJ
CLAGE
CLNO
DEBTINC
dtype: float
The means of df are LOAN
MORTDUE
VALUE
YOJ
CLAGE
CLNO
DEBTINC
dtype: float
The standard deviations of df are LOAN
MORTDUE
VALUE
YOJ
CLAGE
CLNO
DEBTINC
dtype: float
import pandas as pd
from sklearn.preprocessing import StandardScaler, Normalizer
# Read data
hmeq pdreadcsvhmeqsmall.csv
# Fill NaNs
hmeq hmeq.fillnahmeqmean
# Standardize
from sklearn.preprocessing import StandardScaler
standardized StandardScalerfittransformhmeq
df pdDataFramestandardized columnshmeq.columns
# Normalize
from sklearn.preprocessing import Normalizer
normalized Normalizerfittransformhmeq
df pdDataFramenormalized columnshmeq.columns
# Print statistics in correct order
printdfmean
printdfstd
printdfmean
printdfstd
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
