Using Binary Encoding : How to get the original values back from encoded values?How do I sort a list of dictionaries by a value of the dictionary?How to get the ASCII value of a character?How to randomly select an item from a list?How to get the current time in PythonHow do I sort a dictionary by value?How do I get the number of elements in a list in Python?How to access environment variable values?How to do Base64 encoding in node.js?“Large data” work flows using pandasGet statistics for each group (such as count, mean, etc) using pandas GroupBy?
Gift for mentor after his thesis defense?
How to get the decimal part of a number in apex
A♭ major 9th chord in Bach is unexpectedly dissonant/jazzy
Musical Shape on music stand
Picking a theme as a discovery writer
How can I finally understand the confusing modal verb "мочь"?
Convert Numbers To Emoji Math
shebang or not shebang
Extracting the parent, leaf, and extension from a valid path
When will the number of stars be a maximum?
Is throwing dice a stochastic or a deterministic process?
Why doesn't increasing the temperature of something like wood or paper set them on fire?
What's weird about Proto-Indo-European Stops?
Select list elements based on other list
My C Drive is full without reason
How is it believable that Euron could so easily pull off this ambush?
How to increase speed on my hybrid bike with flat handlebars and 700X35C tyres?
How to make a kid's bike easier to pedal
I want to write a blog post building upon someone else's paper, how can I properly cite/credit them?
How to replace space with '+' symbol in a triangular array?
What's the 2-minute timer on mobile Deutsche Bahn tickets?
What's the role of the Receiver/Transmitter in Avengers Endgame?
And now you see it
Drug Testing and Prescribed Medications
Using Binary Encoding : How to get the original values back from encoded values?
How do I sort a list of dictionaries by a value of the dictionary?How to get the ASCII value of a character?How to randomly select an item from a list?How to get the current time in PythonHow do I sort a dictionary by value?How do I get the number of elements in a list in Python?How to access environment variable values?How to do Base64 encoding in node.js?“Large data” work flows using pandasGet statistics for each group (such as count, mean, etc) using pandas GroupBy?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have the below data frame:
data='automobile':['car','car','car','car','scooter','scooter','bike','bike','bike']
df=pd.DataFrame(data)
encoder=ce.BinaryEncoder(cols=['automobile'])
df=encoder.fit_transform(df)
This gives me binary columns which is expected. But while performing clustering analysis how can I get to know which binary value corresponds to which automobile category.
python encoding scikit-learn categorical-data
|
show 1 more comment
I have the below data frame:
data='automobile':['car','car','car','car','scooter','scooter','bike','bike','bike']
df=pd.DataFrame(data)
encoder=ce.BinaryEncoder(cols=['automobile'])
df=encoder.fit_transform(df)
This gives me binary columns which is expected. But while performing clustering analysis how can I get to know which binary value corresponds to which automobile category.
python encoding scikit-learn categorical-data
encoder has a inverse_transform method. have you tried it?
– rdRahul
Mar 23 at 6:26
I read the docs but not exactly able to implement it
– zavy mola
Mar 23 at 6:30
you just need to pass the binary df to the function.how are you trying?
– rdRahul
Mar 23 at 6:32
It says BinaryEncoder object has no attribute inverse_transform
– zavy mola
Mar 23 at 6:37
you are trying encoder.inverse_transform( df ) . right ? seems strange.
– rdRahul
Mar 23 at 6:39
|
show 1 more comment
I have the below data frame:
data='automobile':['car','car','car','car','scooter','scooter','bike','bike','bike']
df=pd.DataFrame(data)
encoder=ce.BinaryEncoder(cols=['automobile'])
df=encoder.fit_transform(df)
This gives me binary columns which is expected. But while performing clustering analysis how can I get to know which binary value corresponds to which automobile category.
python encoding scikit-learn categorical-data
I have the below data frame:
data='automobile':['car','car','car','car','scooter','scooter','bike','bike','bike']
df=pd.DataFrame(data)
encoder=ce.BinaryEncoder(cols=['automobile'])
df=encoder.fit_transform(df)
This gives me binary columns which is expected. But while performing clustering analysis how can I get to know which binary value corresponds to which automobile category.
python encoding scikit-learn categorical-data
python encoding scikit-learn categorical-data
edited Mar 23 at 10:35
desertnaut
21.5k84681
21.5k84681
asked Mar 23 at 5:53
zavy molazavy mola
633
633
encoder has a inverse_transform method. have you tried it?
– rdRahul
Mar 23 at 6:26
I read the docs but not exactly able to implement it
– zavy mola
Mar 23 at 6:30
you just need to pass the binary df to the function.how are you trying?
– rdRahul
Mar 23 at 6:32
It says BinaryEncoder object has no attribute inverse_transform
– zavy mola
Mar 23 at 6:37
you are trying encoder.inverse_transform( df ) . right ? seems strange.
– rdRahul
Mar 23 at 6:39
|
show 1 more comment
encoder has a inverse_transform method. have you tried it?
– rdRahul
Mar 23 at 6:26
I read the docs but not exactly able to implement it
– zavy mola
Mar 23 at 6:30
you just need to pass the binary df to the function.how are you trying?
– rdRahul
Mar 23 at 6:32
It says BinaryEncoder object has no attribute inverse_transform
– zavy mola
Mar 23 at 6:37
you are trying encoder.inverse_transform( df ) . right ? seems strange.
– rdRahul
Mar 23 at 6:39
encoder has a inverse_transform method. have you tried it?
– rdRahul
Mar 23 at 6:26
encoder has a inverse_transform method. have you tried it?
– rdRahul
Mar 23 at 6:26
I read the docs but not exactly able to implement it
– zavy mola
Mar 23 at 6:30
I read the docs but not exactly able to implement it
– zavy mola
Mar 23 at 6:30
you just need to pass the binary df to the function.how are you trying?
– rdRahul
Mar 23 at 6:32
you just need to pass the binary df to the function.how are you trying?
– rdRahul
Mar 23 at 6:32
It says BinaryEncoder object has no attribute inverse_transform
– zavy mola
Mar 23 at 6:37
It says BinaryEncoder object has no attribute inverse_transform
– zavy mola
Mar 23 at 6:37
you are trying encoder.inverse_transform( df ) . right ? seems strange.
– rdRahul
Mar 23 at 6:39
you are trying encoder.inverse_transform( df ) . right ? seems strange.
– rdRahul
Mar 23 at 6:39
|
show 1 more comment
1 Answer
1
active
oldest
votes
if you want to keep Label for 'decoding', i suggest you to use LabelEncoder:
import pandas as pd
from sklearn.preprocessing import LabelEncoder
data = 'automobile': ['car', 'car', 'car', 'car', 'scooter', 'scooter', 'bike', 'bike', 'bike']
df = pd.DataFrame(data)
ler = LabelEncoder().fit(df['automobile'])
df['automobile']=ler.transform(df['automobile'])
dico = dict(zip(ler.classes_, ler.transform(ler.classes_)))
print(df)
print(dico)
output: df
automobile
0 1
1 1
2 1
3 1
4 2
5 2
6 0
7 0
8 0
output: dico
'bike': 0, 'car': 1, 'scooter': 2
if this answer helps you, please, dont forget to uvpvote/validate the answer
– Frenchy
Apr 11 at 15:10
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55311036%2fusing-binary-encoding-how-to-get-the-original-values-back-from-encoded-values%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
if you want to keep Label for 'decoding', i suggest you to use LabelEncoder:
import pandas as pd
from sklearn.preprocessing import LabelEncoder
data = 'automobile': ['car', 'car', 'car', 'car', 'scooter', 'scooter', 'bike', 'bike', 'bike']
df = pd.DataFrame(data)
ler = LabelEncoder().fit(df['automobile'])
df['automobile']=ler.transform(df['automobile'])
dico = dict(zip(ler.classes_, ler.transform(ler.classes_)))
print(df)
print(dico)
output: df
automobile
0 1
1 1
2 1
3 1
4 2
5 2
6 0
7 0
8 0
output: dico
'bike': 0, 'car': 1, 'scooter': 2
if this answer helps you, please, dont forget to uvpvote/validate the answer
– Frenchy
Apr 11 at 15:10
add a comment |
if you want to keep Label for 'decoding', i suggest you to use LabelEncoder:
import pandas as pd
from sklearn.preprocessing import LabelEncoder
data = 'automobile': ['car', 'car', 'car', 'car', 'scooter', 'scooter', 'bike', 'bike', 'bike']
df = pd.DataFrame(data)
ler = LabelEncoder().fit(df['automobile'])
df['automobile']=ler.transform(df['automobile'])
dico = dict(zip(ler.classes_, ler.transform(ler.classes_)))
print(df)
print(dico)
output: df
automobile
0 1
1 1
2 1
3 1
4 2
5 2
6 0
7 0
8 0
output: dico
'bike': 0, 'car': 1, 'scooter': 2
if this answer helps you, please, dont forget to uvpvote/validate the answer
– Frenchy
Apr 11 at 15:10
add a comment |
if you want to keep Label for 'decoding', i suggest you to use LabelEncoder:
import pandas as pd
from sklearn.preprocessing import LabelEncoder
data = 'automobile': ['car', 'car', 'car', 'car', 'scooter', 'scooter', 'bike', 'bike', 'bike']
df = pd.DataFrame(data)
ler = LabelEncoder().fit(df['automobile'])
df['automobile']=ler.transform(df['automobile'])
dico = dict(zip(ler.classes_, ler.transform(ler.classes_)))
print(df)
print(dico)
output: df
automobile
0 1
1 1
2 1
3 1
4 2
5 2
6 0
7 0
8 0
output: dico
'bike': 0, 'car': 1, 'scooter': 2
if you want to keep Label for 'decoding', i suggest you to use LabelEncoder:
import pandas as pd
from sklearn.preprocessing import LabelEncoder
data = 'automobile': ['car', 'car', 'car', 'car', 'scooter', 'scooter', 'bike', 'bike', 'bike']
df = pd.DataFrame(data)
ler = LabelEncoder().fit(df['automobile'])
df['automobile']=ler.transform(df['automobile'])
dico = dict(zip(ler.classes_, ler.transform(ler.classes_)))
print(df)
print(dico)
output: df
automobile
0 1
1 1
2 1
3 1
4 2
5 2
6 0
7 0
8 0
output: dico
'bike': 0, 'car': 1, 'scooter': 2
answered Mar 23 at 8:11
FrenchyFrenchy
2,6162518
2,6162518
if this answer helps you, please, dont forget to uvpvote/validate the answer
– Frenchy
Apr 11 at 15:10
add a comment |
if this answer helps you, please, dont forget to uvpvote/validate the answer
– Frenchy
Apr 11 at 15:10
if this answer helps you, please, dont forget to uvpvote/validate the answer
– Frenchy
Apr 11 at 15:10
if this answer helps you, please, dont forget to uvpvote/validate the answer
– Frenchy
Apr 11 at 15:10
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55311036%2fusing-binary-encoding-how-to-get-the-original-values-back-from-encoded-values%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
encoder has a inverse_transform method. have you tried it?
– rdRahul
Mar 23 at 6:26
I read the docs but not exactly able to implement it
– zavy mola
Mar 23 at 6:30
you just need to pass the binary df to the function.how are you trying?
– rdRahul
Mar 23 at 6:32
It says BinaryEncoder object has no attribute inverse_transform
– zavy mola
Mar 23 at 6:37
you are trying encoder.inverse_transform( df ) . right ? seems strange.
– rdRahul
Mar 23 at 6:39