GithubHelp home page GithubHelp logo

karthickop6 / odd2023-datascience-ex-05 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from karthi-govindharaju/odd2023-datascience-ex-05

0.0 0.0 1.0 7 KB

License: Creative Commons Zero v1.0 Universal

odd2023-datascience-ex-05's Introduction

Ex:05 Feature Generation

AIM:

To read the given data and perform Feature Generation process and save the data to a file.

Explanation:

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.

Algorithm:

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

Program

Encoding data.csv

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

Output:

Initial data

5_1_1

Unique data

5_1_2

Original data

5_1_3

Label Encoder

5_1_4

Binary Encoder

5_1_5 5_1_6

Data.csv

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

Output:

Initial data

5_2_1 5_2_2 5_2_3

Label encoder

5_2_4

OneHotEncoder

5_2_5

Binary Encoder

5_2_6 5_2_7

Result:

The above Feature Generation process has been Executed Seccessfully.

odd2023-datascience-ex-05's People

Contributors

karthi-govindharaju avatar karthickop6 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.