Coder Social home page Coder Social logo

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

CODE AND OUTPUT FOR FEATURE ENCODING AND FEATURE SCALING:

import pandas as pd
import numpy as np
from google.colab import files
upload = files.upload()

image

df = pd.read_csv("bmi.csv")
df

image

from category_encoders import BinaryEncoder
e1 = BinaryEncoder()
bn = e1.fit_transform(df['Gender'])
df = pd.concat([df,bn],axis = 1)
df

image

from sklearn.preprocessing import RobustScaler
rs = RobustScaler()
df[['Height','Weight']] = rs.fit_transform(df[['Height','Weight']])
df

image

from google.colab import files
upload = files.upload()

image

df = pd.read_csv("data1.csv")
df

image

from sklearn.preprocessing import OrdinalEncoder,LabelEncoder,OneHotEncoder
data = ['Very Hot','Hot','Warm','Cold']
e1 = OrdinalEncoder(categories = [data])
df['Ord_1'] = e1.fit_transform(df[['Ord_1']])
df

image

data1 = ['High School','Diploma','Bachelors','Masters','PhD']
e1 = LabelEncoder()
df['Ord_2'] = e1.fit_transform(df['Ord_2'])
df

image

e2 = OneHotEncoder(sparse = False)
enc = pd.DataFrame(e2.fit_transform(df[['City']]))
df = pd.get_dummies(df,columns = ['City'])
df

image

pip install --upgrade category_encoders
from category_encoders import BinaryEncoder
e3 = BinaryEncoder()
bn = e3.fit_transform(df[['bin_1','bin_2']])
df = pd.concat([df,bn],axis = 1)
df

image

from sklearn.preprocessing import MinMaxScaler
mm = MinMaxScaler()
df[['Ord_1','Ord_2']] = mm.fit_transform(df[['Ord_1','Ord_2']])
df

image

from google.colab import files
upload = files.upload()

image

df = pd.read_csv("Encoding Data.csv")
df

image

from sklearn.preprocessing import LabelEncoder,OneHotEncoder
data1 = ['Hot','Warm','Cold']
e1 = LabelEncoder()
df['ord_2'] = e1.fit_transform(df['ord_2'])
df

image

e2 = OneHotEncoder(sparse = False)
enc = pd.DataFrame(e2.fit_transform(df[['nom_0']]))
df = pd.get_dummies(df,columns = ['nom_0'])
df```

image

from category_encoders import BinaryEncoder
e3 = BinaryEncoder()
bn = e3.fit_transform(df[['bin_1','bin_2']])
df = pd.concat([df,bn],axis = 1)
df

image

from sklearn.preprocessing import  StandardScaler
ss = StandardScaler()
df[['ord_2']] = ss.fit_transform(df[['ord_2']])
df

image

RESULT:

Feature Encoding process and Feature Scaling process is applied to the given data frame sucessfully.

odd2023-datascience-ex-05's People

Contributors

karthi-govindharaju avatar sudhar2303 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.