User-Based Collaborative Filtering is a technique used to predict the items that a user might like on the basis of ratings given to that item by the other users who have similar taste with that of the target user.

Many websites use collaborative filtering for building their recommendation system.

**Steps for User-Based Collaborative Filtering: **

**Step 1: Finding the similarity of users to the target user U.**

Similarity for any two users *‘a’* and *‘b’* can be calculated from the given formula,

**Step 2: Prediction of missing rating of an item**

Now, the target user might be very similar to some users and may not be much similar to the others. Hence, the ratings given to a particular item by the more similar users should be given more weightage than those given by less similar users and so on. This problem can be solved by using a weighted average approach. In this approach, you multiply the rating of each user with a similarity factor calculated using the above mention formula.

The missing rating can be calculated as,

**Example:**Consider a matrix which shows four users

*Alice, U1, U2 and U3*rating on different news apps. The rating range is from 1 to 5 on the basis of users likability of the news app. The

*‘?’*indicates that the app has not been rated by the user.

Name |
Inshorts(I1) |
HT(I2) |
NYT(I3) |
TOI(I4) |
BBC(I5) |

Alice |
5 | 4 | 1 | 4 | ? |

U1 |
3 | 1 | 2 | 3 | 3 |

U2 |
4 | 3 | 4 | 3 | 5 |

U3 |
3 | 3 | 1 | 5 | 4 |

**Step 1: Calculating the similarity between Alice and all the other users**

At first we calculate the averages of the ratings of all the user excluding I5 as it is not rated by Alice. Therefore, we calculate the average as ,

Therefore, we have

and calculate the new ratings as,

Hence, we get the following matrix,

Name |
Inshorts(I1) |
HT(I2) |
NYT(I3) |
TOI(I4) |

Alice |
1.5 | 0.5 | -2.5 | 0.5 |

U1 |
0.75 | -1.25 | -0.25 | 0.75 |

U2 |
0.5 | -0.5 | 0.5 | -0.5 |

U3 |
0 | 0 | -2 | 2 |

Now, we calculate the similarity between Alice and all the other users.

**Step 2: Predicting the rating of the app not rated by Alice**

Now, we predict Alice’s rating for BBC News App,

Hence, with the help of a small example we tried to understand the working of User-based collaborative filtering.

## Recommended Posts:

- Collaborative Filtering - ML
- Item-to-Item Based Collaborative Filtering
- NLP | Training a tokenizer and filtering stopwords in a sentence
- Detecting Covid-19 with Chest X-ray
- Understanding of OpenSeq2Seq
- Implementation of Radius Neighbors from Sratch in Python
- Open AI GPT-3
- NLP - Expand contractions in Text Processing
- Intuition of Adam Optimizer
- NLP Sequencing
- Implementation of Logistic Regression from Scratch using Python
- Intuition of SpanBert
- Vectorization Of Gradient Descent
- Regularization by Early Stopping

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.