Giter Site home page Giter Site logo

odd2023-datascience-ex-05's Introduction

Ex:05 Feature Generation

AIM

To read the given data and perform Feature Encoding & Scaling process and save the data to a file.

ALGORITHM

  1. Read the given Data.
  2. Clean the Data Set using Data Cleaning Process
  3. Apply Feature Generation techniques to all the feature of the data set
  4. Save the data to the file

CODE

import pandas as pd
df=pd.read_csv("/content/Encoding Data.csv")
df

image

from sklearn.preprocessing import LabelEncoder,OrdinalEncoder
pn=['Hot','Warm','Cold']
e1=OrdinalEncoder(categories=[pn])
e1.fit_transform(df[['ord_2']])
df['bo2']=e1.fit_transform(df[['ord_2']])
df

image

le=LabelEncoder()
dfc=df.copy()
dfc['ord_2']=le.fit_transform(dfc['ord_2'])
dfc

image

from sklearn.preprocessing import OneHotEncoder
ohe=OneHotEncoder()#sparse=False
df2=df.copy()
enc=pd.DataFrame(ohe.fit_transform(df2[['nom_0']]))
df2=pd.concat([df2,enc],axis=1)
df2

image

pd.get_dummies(df2,columns=["nom_0"])

image

pip install category_encoders

image

from category_encoders import BinaryEncoder
be=BinaryEncoder()
dfb=df.copy()
nd=be.fit_transform(df['ord_2'])
dfb=pd.concat([dfb,nd],axis=1)
dfb

image

df=pd.read_csv("/content/data.csv")
df

image

from category_encoders import TargetEncoder
te=TargetEncoder()
cc=df.copy()
new=te.fit_transform(X=cc["City"],y=cc["Target"])
cc=pd.concat([cc,new],axis=1)
cc

image

import pandas as pd
df=pd.read_csv("/content/bmi.csv")
df

image

import numpy as np
max_vals=np.max(np.abs(df[['Height','Weight']]))
max_vals

image

min_vals=np.min(np.abs(df[['Height','Weight']]))
min_vals

image

from sklearn.preprocessing import StandardScaler
sc=StandardScaler()
df1=df.copy()
df1[["Height","Weight"]]=sc.fit_transform(df1[["Height","Weight"]])
df1.head(10)

image

max_val=np.max(np.abs(df1[['Height','Weight']]))
max_val

image

min_val=np.min(np.abs(df1[['Height','Weight']]))
min_val

image

from sklearn.preprocessing import MinMaxScaler
sc=MinMaxScaler()
df2=df.copy()
df2[["Height","Weight"]]=sc.fit_transform(df2[["Height","Weight"]])
df2

image

from sklearn.preprocessing import Normalizer
sc=Normalizer()
df3=df.copy()
df3[["Height","Weight"]]=sc.fit_transform(df3[["Height","Weight"]])
df3

image

from sklearn.preprocessing import MaxAbsScaler
sc=MaxAbsScaler()
df4=df.copy()
df4[["Height","Weight"]]=sc.fit_transform(df4[["Height","Weight"]])
df4

image

from sklearn.preprocessing import RobustScaler
sc=RobustScaler()
df5=df.copy()
df5[["Height","Weight"]]=sc.fit_transform(df5[["Height","Weight"]])
df5

image

RESULT:

This Program has run successfully.

odd2023-datascience-ex-05's People

Contributors

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