I am writing a music recommendation system using machine learning. I'm attempting to make sense of ensemble networks to allow the system to learn from both the content-based features, as well as the global 'meta' features, such as the genre, year, artist etc.

However, I do not know how I should represent the genre and artist information. Making them integers would imply some sort of order. If Kanye West is 24, what should 25 be? 26?

Or is there something fundamentally wrong with my approach?


1 Answer 1


You can represent this kind of discrete information by means of embeddings.

An embedding is simply a table of vectors. It is defined by the number of vectors in the table and the length of each vector (i.e. dimensionality). You need to define a priori all the elements you want to support, e.g. for genres, you should list all the genres you will support, and list them. The index of each item is how you represent it.

You can have an embedding for each of the discrete features you need (genre, artist, etc).

In Keras, there is a layer for Embeddings.

  • $\begingroup$ Thanks for answering! I'll look into this. $\endgroup$ Commented Oct 31, 2020 at 15:15
  • $\begingroup$ If you find the answer useful, please consider upvoting it and marking it as correct. $\endgroup$
    – noe
    Commented Oct 31, 2020 at 17:11
  • $\begingroup$ Hi. I've continued to look into your solution. However for a dataset with thousands of artists, and the possibility of adding new artists, this solution does not seem to be feasible. Or am I mistaken? $\endgroup$ Commented Nov 9, 2020 at 14:04
  • $\begingroup$ In order to add new artists, you would need to retrain. $\endgroup$
    – noe
    Commented Nov 9, 2020 at 14:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.