Scaling and transformations

Feature Engineering for Machine Learning in Python

Robert O'Callaghan

Data Scientist

Scaling data

Feature Engineering for Machine Learning in Python

Min-Max scaling

Minmax shrink

Feature Engineering for Machine Learning in Python

Min-Max scaling

Feature Engineering for Machine Learning in Python

Min-Max scaling in Python

from sklearn.preprocessing import MinMaxScaler

scaler = MinMaxScaler()

scaler.fit(df[['Age']])

df['normalized_age'] = scaler.transform(df[['Age']])
Feature Engineering for Machine Learning in Python

Standardization

Feature Engineering for Machine Learning in Python

Standardization in Python

from sklearn.preprocessing import StandardScaler

scaler = StandardScaler()

scaler.fit(df[['Age']])

df['standardized_col'] = scaler\
                        .transform(df[['Age']])
Feature Engineering for Machine Learning in Python

Log Transformation

log image

Feature Engineering for Machine Learning in Python

Log transformation in Python

from sklearn.preprocessing import PowerTransformer

log = PowerTransformer()

log.fit(df[['ConvertedSalary']])

df['log_ConvertedSalary'] = 
     log.transform(df[['ConvertedSalary']])
Feature Engineering for Machine Learning in Python

Final Slide

Feature Engineering for Machine Learning in Python

Preparing Video For Download...