CategoricalEmbedder icon indicating copy to clipboard operation
CategoricalEmbedder copied to clipboard

Problems in getting embeddings

Open Carla-ifr opened this issue 5 years ago • 2 comments

Hi @Shivanandroy,

I also have the same problem in this point of the code.

  embeddings = ce.get_embeddings(X_train, y_train, categorical_embedding_info=embedding_info, is_classification=False, 
  epochs=100,batch_size=256)

I am running the code on google colab and the issue that is being shown is in the pdf attached to this msg. issue.ipynb - Colaboratory.pdf

Thanks a lot for your help!

Have a great day!

Carla-ifr avatar Sep 15 '20 17:09 Carla-ifr

Hello! anyone here can help with this problem : ) ? Thanks in advance

Carla-ifr avatar Sep 18 '20 18:09 Carla-ifr

@Carla-ifr , This repo is deprecated and is no longer maintained.

To solve you problem, you may need to downgrade the dependencies

!pip install tensorflow_addons==0.8.3
!pip install tqdm==4.41.1
!pip install keras==2.3.1
!pip install tensorflow==2.2.0

Then,

import categorical_embedder as ce
embedding_info = ce.get_embedding_info(X)
X_encoded,encoders = ce.get_label_encoded_data(X)

embeddings = ce.get_embeddings(X, y, categorical_embedding_info=embedding_info, 
                            is_classification=True, epochs=100, batch_size=256)
embeddings_df = ce.get_embeddings_in_dataframe(embeddings, encoders)

Now, embeddings_df will have the embeddings of every categorical variables, you can access them by

embeddings_df['education']

                 education_embedding_0	education_embedding_1
Bachelor's	         0.226899	             0.150172
Below Secondary	          0.438177	              0.406307
Master's & above	 0.071212	            0.054443

Now - Just map these embeddings in your data against your categorical variables

Shivanandroy avatar Sep 18 '20 20:09 Shivanandroy