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;








0















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.










share|improve this question
























  • 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

















0















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.










share|improve this question
























  • 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













0












0








0








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.










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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

















  • 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












1 Answer
1






active

oldest

votes


















1














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





share|improve this answer























  • if this answer helps you, please, dont forget to uvpvote/validate the answer

    – Frenchy
    Apr 11 at 15:10











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
);



);













draft saved

draft discarded


















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









1














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





share|improve this answer























  • if this answer helps you, please, dont forget to uvpvote/validate the answer

    – Frenchy
    Apr 11 at 15:10















1














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





share|improve this answer























  • if this answer helps you, please, dont forget to uvpvote/validate the answer

    – Frenchy
    Apr 11 at 15:10













1












1








1







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





share|improve this answer













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






share|improve this answer












share|improve this answer



share|improve this answer










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

















  • 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



















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript