Prepare the data
Create a permissioned user-item rating table and reserve some observed ratings for evaluation.
Learn from ratings. Suggest something relevant.
User-based collaborative filtering finds people with similar ratings and uses their preferences to suggest unseen items. A small matrix makes sparsity, missing values and popularity bias easy to inspect.
Learning concept · Not a validated service
User-based collaborative filtering finds people with similar ratings and uses their preferences to suggest unseen items. A small matrix makes sparsity, missing values and popularity bias easy to inspect.
A possible application for reading clubs: Help a reading club suggest books from voluntary ratings while letting members ignore or reset their recommendations. This extension is not delivered by the supplied starter.
Create a permissioned user-item rating table and reserve some observed ratings for evaluation.
Compute cosine similarity, exclude the target user and rank unseen items from neighbouring users.
Compare precision at k and catalogue coverage against a popularity baseline; test a new user with no history.
Show a small recommendation list with a popularity fallback and a dismiss action.
The supplied starter creates twelve ratings from four users across five items. It fills missing ratings with zero, computes user-to-user cosine similarity and ranks unseen items using the most similar user’s ratings.
matrix = ratings.pivot_table(
index="user", columns="item", values="rating"
).fillna(0)
user_similarity = pd.DataFrame(
cosine_similarity(matrix), index=matrix.index, columns=matrix.index
)
neighbor = user_similarity[target_user].drop(target_user).idxmax()
unseen_items = matrix.loc[target_user][matrix.loc[target_user] == 0].index
scores = matrix.loc[neighbor, unseen_items].sort_values(ascending=False)The source demonstrates the basic similarity mechanism, but not reliable recommendation quality. There is no held-out ranking evaluation or cold-start fallback. Zero represents an unknown rating, not dislike, and one neighbour can leave candidate items unscored.
Proposed extension: Help a reading club suggest books from voluntary ratings while letting members ignore or reset their recommendations.
This is a potential application pathway, not a delivered product. The supplied starter does not implement this service or validate it with real users.
Networkers Home runs this topic inside its AI Engineer Course, with placement support and hands-on labs.