To read the given data and perform Feature Generation process and save the data to a file.
Feature Generation (also known as feature construction, feature extraction or feature engineering) is the process of transforming features into new features that better relate to the target.
Step 1: Read the given Data.
Step 2: Clean the Data Set using Data Cleaning Process.
Step 3: Apply Feature Generation techniques to all the feature of the data set.
Step 4: Save the data to the file.
Name: Karthick P
Register Number: 212222100021
import pandas as pd
df=pd.read_csv('Encoding Data.csv')
df.head()
df['ord_2'].unique()
from sklearn.preprocessing import LabelEncoder,OrdinalEncoder
climate = ['Cold','Warm','Hot']
en= OrdinalEncoder(categories = [climate])
df['ord_2']=en.fit_transform(df[["ord_2"]])
df
le = LabelEncoder()
df['Nom_0'] = le.fit_transform(df[["nom_0"]])
df
from category_encoders import BinaryEncoder
be = BinaryEncoder()
data = be.fit_transform(df['bin_1'])
df = pd.concat([df,data],axis=1)
df
be = BinaryEncoder()
data = be.fit_transform(df['bin_2'])
df = pd.concat([df,data],axis=1)
df
import pandas as pd
import numpy as np
from scipy import stats
import seaborn as sns
import matplotlib.pyplot as plt
data=pd.read_csv("/content/data.csv")
df=pd.DataFrame(data)
df
from sklearn.preprocessing import LabelEncoder, OrdinalEncoder
pm=['Hot','Warm','Cold','Very Hot']
e1=OrdinalEncoder(categories=[pm])
e1.fit_transform(df[["Ord_1"]])
df['bo2']=e1.fit_transform(df[["Ord_1"]])
df
le=LabelEncoder()
dfc=df.copy()
dfc['Ord_1']=le.fit_transform(dfc['Ord_1'])
dfc
from sklearn.preprocessing import OneHotEncoder
ohe=OneHotEncoder(sparse=False)
df2=df.copy()
enc=pd.DataFrame(ohe.fit_transform(df2[['City']]))
df2=pd.concat([df2,enc],axis=1)
pd.get_dummies(df2,columns=["City"])
from category_encoders import BinaryEncoder
be = BinaryEncoder()
data = be.fit_transform(dfc['bin_1'])
dfc = pd.concat([dfc,data],axis=1)
dfc
be1 = BinaryEncoder()
data = be1.fit_transform(dfc['bin_2'])
dfc = pd.concat([dfc,data],axis=1)
dfc
The above Feature Generation process has been Executed Seccessfully.