Question

Consider the user book-rating matrix given below. The ratings increase from 1 to 5. Absence of a rating is indicated by empty box.

    \[ \begin{tabular}{|c|c|c|c|c|c|c|c|c|} \hline User/Book & b1 & b2 & b3 & b4 & b5 & b6 & b7\\ \hline U1 & 4 & 1 & _ & 5 & _ & _ & 2\\ \hline U2 & 5 & 1 & _ & 2 & 3 & _ & 4\\ \hline U3 & _ & 1 & _ & 4 & 4 & 1 & 1\\ \hline U4 & 3 & _ & 1 & 1 & _ & 5 & 3\\ \hline \end{tabular} \]

A new book b8 is published and U4 liked it. Identify which user is most likely interested in the book b8 using collaborative filtering approach and cosine similarity as a similarity measure.

Solution

==================================================================================================
Here, we need to find Cosine Similarity of all other users with U4 and then recommend b8 to the user most similar to U4.

    \begin{align*}  \boxed{Cosine \ Similarity = \frac{x.y}{\lVert x \rVert \lVert y \rVert} } \end{align*}

    \begin{align*} \left CS(U1,U4) = \frac{U1.U4}{\lVert U1 \rVert \lVert U4 \rVert} = \frac{(4,1,0,5,0,0,2).(3,0,1,1,0,5,3)}{6.78 * 6.71} = \frac{23}{45.49} = 0.51 \end{align*}

    \begin{align*} \left CS(U2,U4) = \frac{U2.U4}{\lVert U2 \rVert \lVert U4 \rVert} = \frac{(5,1,0,2,3,0,4).(3,0,1,1,0,5,3)}{7.42 * 6.71} = \frac{29}{49.79} = 0.58 \end{align*}

    \begin{align*} \left CS(U3,U4) = \frac{U3.U4}{\lVert U3 \rVert \lVert U4 \rVert} = \frac{(0,1,0,4,4,1,1).(3,0,1,1,0,5,3)}{5.92 * 6.71} = \frac{12}{39.72} = 0.3 \end{align*}

Thus, we can see that U4 and U2 are most similar and hence, b8 should be recommended to U2.

Subscribe to Ehan Ghalib!

Invalid email address
We promise not to spam you. You can unsubscribe at any time.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>