Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started