Prepare interaction data
Collect user-item interactions (ratings, purchases or likes) and pivot into a user-item matrix, filling missing values appropriately.
Recommend via social similarity. Account for neighbour preferences.
Social recommendation uses user-to-user relationships (explicit or implicit) to suggest items liked by similar people. Key issues include sparse interactions, popularity and echo-chamber effects, cold-start users and items, and privacy of social signals.
Learning concept · Not a validated service
Social recommendation uses user-to-user relationships (explicit or implicit) to suggest items liked by similar people. Key issues include sparse interactions, popularity and echo-chamber effects, cold-start users and items, and privacy of social signals.
A proposed extension: a small retail app that suggests products to a user from items liked by their most similar shoppers, with a review step for merchants before exposure to customers.
Collect user-item interactions (ratings, purchases or likes) and pivot into a user-item matrix, filling missing values appropriately.
Measure pairwise user similarity (for example cosine) on the interaction vectors and identify nearest neighbours for each user.
For a target user, aggregate neighbour preferences over items the target has not seen and rank by neighbour scores or weighted similarity.
Use offline ranking metrics (Precision@K, Recall@K, NDCG) on a held-out set and inspect popularity bias and cold-start failures.
The supplied starter creates a toy ratings DataFrame for five users and five items, pivots it to a user-item matrix, computes cosine similarity between users, selects the most similar user to a target, and prints that neighbour plus the neighbour's highest-rated unseen items.
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,
)The starter uses only a tiny hand-crafted rating table and no social-network signals, item metadata or production features; it does not compute offline ranking metrics, handle ties or multiple neighbours, nor address cold-start or scaling concerns.
A proposed extension: replace the toy table with real interaction logs, compute k-nearest neighbours with similarity weighting, and add business rules for diversity and safety before serving 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.