We have encountered enough variants of the KNNalgorithm for it be our first choice for solving the recommendation problem. In the user-item rating matrix from the previous section, each row represents a user and each column represents an item. Thus, similar rows represent users who have similar tastes and identical columns represent items liked by the same users. Therefore, if we want to estimate the rating (ru,i),given by the user (u) to the item (i), we can get the KNNs to the user (u), find their ratings for the item (i), and calculate the average of their rating as an estimate for (ru,i). Nevertheless, since some of these neighbors are more similar to the user (u) than others, we may need to use a weighted average instead. Ratings given by more similar users should be given more weight than the others. Here is a formula where a similarity score is used to weigh the ratings given by the user's neighbors:
...