Python for Machine Learning – Part 16 – Label Encoding – Preprocessing

Topic to be covered – Label Encoding

import pandas as pd
import numpy as np

df = pd.read_csv(‘Datapreprocessing.csv’)

# Get the rows that contains NULL (NaN)

# Fill the NaN values for Occupation, Emplyment Status and Employement Type

col = [‘Occupation’,’Employment Status’,’Employement Type’]
df[col] = df[col].fillna(df.mode().iloc[0])

features = df.iloc[:,:-1].values

labels = df.iloc[:,-1].values

from sklearn.preprocessing import Imputer, OneHotEncoder

imputer =…


Leave a Reply

Your email address will not be published.