1
$\begingroup$

Hello I am trying to make a content based movie recommendation system and one feature is genre of the movie. I will give an integer number to each genre randomly. However, some movies are of more than 1 genre. I will use tf-idf for weigthing these features. However, I am very confused that what to do when a movie is horror and action and comedy movie at the same time. Should I multiply or add these weighted features, I have no idea. Also I do not know why we use weighting in the first place at all. Can you help me get through this? By the way, let me say that each movie will be regarded as a document and then tf-idf calculation is done on them.

$\endgroup$
1
$\begingroup$

That's a good question. This task would be referred to as multi-label encoding. Bascially if a movie belongs to several genres, you one hot-encode each genre and add the vectors.

If there were only 6 genres (horror, romance, action, adventure, comedy, fantasy) For instance a movie that is horror, action and comedy (The Dead don't Die?):

  • horror = [1, 0, 0, 0, 0, 0]
  • action = [0, 0, 1, 0, 0, 0]
  • comedy = [0, 0, 0, 0, 1, 0]

So a movie that belongs to all three would be encoded as: [1, 0, 1, 0, 1, 0]. A movie that only has a category then its encoding is a one-hot encoded label.

You can perform this task in scikit-learn with a multi label binarizer

$\endgroup$
3
  • $\begingroup$ so a movie vector is consisting of genre/release date interval/director/main actor in my design. so it will be like 40D or something like that if there are 10 distinct directors and 20 main actors and 4 release date intervals(2000-2005,2006-2011 etc.) and the vector will be sparse right? I think it is not important the order of features I believe. $\endgroup$ – OnurTR Apr 1 at 13:15
  • $\begingroup$ by the way is it correct my approach to weigh features? $\endgroup$ – OnurTR Apr 1 at 13:17
  • $\begingroup$ That's fine actually, because recommendation will be based on distances and there are distance adapted for sparse data and this will make the computations faster. You are right, the order is not important as long as it remains consistent. Your idea to add some nlp in there is good, you can try with and without and compare the results. $\endgroup$ – RonsenbergVI Apr 1 at 13:23

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