Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Learning Vector Representation #11

Open
SarahSalamati opened this issue Sep 2, 2022 · 3 comments
Open

Learning Vector Representation #11

SarahSalamati opened this issue Sep 2, 2022 · 3 comments
Assignees
Labels

Comments

@SarahSalamati
Copy link
Contributor

SarahSalamati commented Sep 2, 2022

What is one hot encoding?
One hot encoding is one way to prepare data for an algorithm and improve prediction for categorical data, which are variables made up of label values. With one-hot, we create a new category column for each categorical value and give it a binary value of 1 or 0. A binary vector is used to represent each integer value. The index is denoted by a 1 and all values are zero.

why do we use it?
It is useful for data that has no relationship to each other.

One hot encoding with Pandas
In Pandas library, there is a function called get dummies to provide one-hot encoding.

Sample of coding One hot encoding
import pandas as name
name2 = name.DataFrame({"col":["sara","ehsan","hossein", "negar","hana"]})
print("The original data")
print(name2)
print('*'*50)
name2_new = name.get_dummies(name2, columns=["col"], prefix="student")
print("The transform data using get_dummies")
print(name2_new)

One hot encoding with Sckit-learn
In Sckit- learn library, there is a function called preprocessing module for One hot encoding.
#Coding

@SarahSalamati SarahSalamati self-assigned this Sep 2, 2022
@hosseinfani
Copy link
Member

@SarahSalamati good job. If you put some examples for more clarification, would be awesome.

@SarahSalamati
Copy link
Contributor Author

Thanks, Hossein. I have written example code in the panda and skit-learn library, so I will add them. Does it work?

@hosseinfani
Copy link
Member

hosseinfani commented Sep 4, 2022

Thanks, Hossein. I have written example code in the panda and skit-learn library, so I will add them. Does it work?

sure! put them here also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants