Sunday, August 9, 2026

Movie Genere association and movie recommendation

 

Movie → Genre Association

Now, let's assume the recommendation engine has analyzed the movies in its catalog and determined how strongly each movie is associated with different genres.

For example, consider the following genres:

  • Action
  • Comedy
  • Drama
  • Sci-Fi
  • Romance

The association can be represented using a numerical value between 0 and 1, where:

  • 0 → The movie has no association with the genre
  • 1 → The movie is very strongly associated with the genre
  • Values between 0 and 1 → The movie has some degree of association with the genre

For example, consider three movies:

MovieActionComedyDramaSci-FiRomance
Movie A0.90.10.20.80.0
Movie B0.10.90.60.00.5
Movie C0.20.10.90.10.8

This tells us that:

  • Movie A is primarily an Action + Sci-Fi movie.
  • Movie B is primarily a Comedy + Drama + Romance movie.
  • Movie C is primarily a Drama + Romance movie.

These numbers could be generated by the recommendation system using information such as movie metadata, descriptions, user ratings, viewing behavior, actors, directors, or even embeddings generated by a machine learning model.


Representing the User and Movie as Vectors

Now we have two different vectors.

The user preference vector represents how much the user likes each genre.

For example:

User=[0.9, 0.2, 0.7, 1.0, 0.1]User = [0.9,\ 0.2,\ 0.7,\ 1.0,\ 0.1]

The positions correspond to:

[Action, Comedy, Drama, SciFi, Romance][Action,\ Comedy,\ Drama,\ Sci-Fi,\ Romance]

So this user:

  • Likes Action strongly → 0.9
  • Has low interest in Comedy → 0.2
  • Likes Drama → 0.7
  • Likes Sci-Fi very strongly → 1.0
  • Has little interest in Romance → 0.1

Similarly, Movie A can be represented as:

MovieA=[0.9, 0.1, 0.2, 0.8, 0.0]Movie_A = [0.9,\ 0.1,\ 0.2,\ 0.8,\ 0.0]

Now the recommendation engine has converted both the user's preferences and the movie's characteristics into vectors.

The important question is:

How can we mathematically determine how well these two vectors match?

This is where the dot product becomes useful.


Calculating the Dot Product

The dot product of two vectors is calculated by multiplying corresponding elements and then adding all the results.

For our user and Movie A:

UserMovieAUser \cdot Movie_A =(0.9×0.9)+(0.2×0.1)+(0.7×0.2)+(1.0×0.8)+(0.1×0.0)= (0.9 \times 0.9) + (0.2 \times 0.1) + (0.7 \times 0.2) + (1.0 \times 0.8) + (0.1 \times 0.0)

Calculating each contribution:

=0.81+0.02+0.14+0.80+0= 0.81 + 0.02 + 0.14 + 0.80 + 0

Therefore:

UserMovieA=1.77\boxed{User \cdot Movie_A = 1.77}

This 1.77 is the compatibility score between the user and Movie A.


What Does Each Number Contribute?

This is where the mathematics becomes particularly interesting.

We can see exactly how much each genre contributes to the final recommendation score:

GenreUser PreferenceMovie AssociationContribution
Action0.90.90.81
Comedy0.20.10.02
Drama0.70.20.14
Sci-Fi1.00.80.80
Romance0.10.00.00
Total1.77

This gives us an intuitive interpretation of the dot product.

Action contributes 0.81

The user strongly likes Action:

0.90.9

and Movie A is strongly associated with Action:

0.90.9

Therefore:

0.9×0.9=0.810.9 \times 0.9 = 0.81

Action makes a large contribution to the recommendation score.

Sci-Fi contributes 0.80

The user has an extremely high preference for Sci-Fi:

1.01.0

and Movie A has a strong Sci-Fi association:

0.80.8

Therefore:

1.0×0.8=0.801.0 \times 0.8 = 0.80

Again, this genre contributes significantly to the overall score.

Comedy contributes only 0.02

The user has very little preference for Comedy:

0.20.2

and Movie A has only a small Comedy association:

0.10.1

Therefore:

0.2×0.1=0.020.2 \times 0.1 = 0.02

Comedy has almost no influence on the final recommendation score.

Romance contributes 0

The user has very little interest in Romance:

0.10.1

and Movie A has no Romance association:

0.00.0

Therefore:

0.1×0=00.1 \times 0 = 0

Romance contributes nothing to the score.


Now Calculate the Score for Every Movie

The recommendation engine doesn't stop with Movie A.

It performs the same calculation for every movie in the catalog.

For Movie B:

MovieB=[0.1, 0.9, 0.6, 0.0, 0.5]Movie_B = [0.1,\ 0.9,\ 0.6,\ 0.0,\ 0.5]

Therefore:

UserMovieBUser \cdot Movie_B =(0.9×0.1)+(0.2×0.9)+(0.7×0.6)+(1.0×0.0)+(0.1×0.5)= (0.9 \times 0.1) + (0.2 \times 0.9) + (0.7 \times 0.6) + (1.0 \times 0.0) + (0.1 \times 0.5) =0.09+0.18+0.42+0+0.05= 0.09 + 0.18 + 0.42 + 0 + 0.05 =0.74\boxed{= 0.74}

For Movie C:

MovieC=[0.2, 0.1, 0.9, 0.1, 0.8]Movie_C = [0.2,\ 0.1,\ 0.9,\ 0.1,\ 0.8]

Therefore:

UserMovieCUser \cdot Movie_C =(0.9×0.2)+(0.2×0.1)+(0.7×0.9)+(1.0×0.1)+(0.1×0.8)= (0.9 \times 0.2) + (0.2 \times 0.1) + (0.7 \times 0.9) + (1.0 \times 0.1) + (0.1 \times 0.8) =0.18+0.02+0.63+0.10+0.08= 0.18 + 0.02 + 0.63 + 0.10 + 0.08 =1.01\boxed{= 1.01}

We now have:

MovieCompatibility Score
Movie A1.77
Movie B0.74
Movie C1.01

So the recommendation engine would rank:

Movie A>Movie C>Movie B\boxed{Movie\ A > Movie\ C > Movie\ B}

Based purely on these genre preferences, Movie A would be the strongest recommendation for this user.


The Key Mathematical Insight

The important thing to understand is that the dot product isn't simply asking:

"Does the user like this movie?"

Instead, it is calculating:

"How strongly do the user's preferences overlap with the characteristics of this movie?"

Mathematically:

Score(User,Movie)=i=1nUseri×Moviei\boxed{ Score(User,Movie) = \sum_{i=1}^{n} User_i \times Movie_i }

Each genre creates a small contribution to the final score.

The recommendation score is simply the sum of all these contributions:

Score=Actioncontribution+Comedycontribution+Dramacontribution+SciFicontribution+RomancecontributionScore = Action_{contribution} + Comedy_{contribution} + Drama_{contribution} + SciFi_{contribution} + Romance_{contribution}

This is why the dot product is so important in machine learning.

It allows us to convert multiple dimensions of information into a single numerical compatibility score.


Taking This One Step Further

In a real recommendation system, we wouldn't have just 5 genres and 3 movies.

We might have:

  • millions of users
  • millions of movies
  • hundreds or thousands of latent features
  • billions of user-movie interactions

Instead of explicitly storing genres, machine-learning algorithms can learn hidden or latent features such as:

  • preference for fast-paced content
  • preference for complex storylines
  • preference for specific actors
  • preference for particular directors
  • preference for dark themes
  • preference for family-oriented content
  • preference for older movies
  • preference for short/long movies

The user and movie can then be represented as high-dimensional vectors:

User=[u1,u2,u3,,un]User = [u_1,u_2,u_3,\ldots,u_n] Movie=[m1,m2,m3,,mn]Movie = [m_1,m_2,m_3,\ldots,m_n]

and the predicted preference becomes:

r^user,movie=UserMovie=i=1nuimi\boxed{ \hat{r}_{user,movie} = User \cdot Movie = \sum_{i=1}^{n}u_i m_i }

This is the fundamental mathematical idea behind latent-factor recommendation models such as matrix factorization.

And this is where our simple five-dimensional example connects directly to much larger machine-learning systems used by real-world recommendation engines.

No comments:

Post a Comment