Daily Data Science Interview Questions:

Matt Chang
2 min readMay 19, 2023

--

(Facebook/ System Design question) :

How would you design a ‘friends you may know’ feature on Facebook? This feature is meant to recommend people that a user may know, based on the list of this user’s friends and possibly other data.
Explain clearly what data would you need and how to best structure them. Suggest a specific model or an algorithm that can be used.

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —
To implement this feature, you would need to consider several factors and utilize appropriate data structures, algorithms, and models.

Data Collection:
This information is typically readily available within the Facebook database. #facebook Gather other relevant user data, such as demographic information, education, work history, location, interests, mutual friends, and any other available data points that might aid in making accurate recommendations.

Data Preprocessing:
Cleanse and normalize the data: Standardize and preprocess the collected data to ensure consistency and remove any inconsistencies or noise. For example, convert text to lowercase, handle missing values, and remove duplicates.

Feature extraction:
Extract meaningful features from the data. This could involve creating feature vectors for each user, representing their attributes, interests, and connections.

Similarity Measurement:
Define a similarity metric: Choose an appropriate similarity metric to quantify the similarity between users. This could be based on common interests, mutual friends, location proximity, or other relevant factors. Common metrics include Jaccard similarity, cosine similarity, or Euclidean distance.

Calculate user similarity scores:
For each user, compare their features with other users’ features using the chosen similarity metric. Calculate similarity scores between users to determine the strength of their potential connection.

Friend Recommendation Algorithm:
Neighborhood-based algorithm: One approach is to utilize a neighborhood-based algorithm like Collaborative Filtering. This algorithm predicts potential friends by finding users with similar interests, connections, or attributes.

Ranking and Filtering:
Rank potential friends: Sort the recommended users based on their similarity scores, listing the most relevant potential friends at the top.

Filter out existing friends: Exclude users already in the user’s friend list from the recommendation list to avoid redundant suggestions.
User Feedback and Refinement:

Cheers, Happy learning!

Matt

#datascience #interview #design #data #learning #dataanalysis #project #computing #statistics #network #algorithms #sql #engagement #userexperience #training #transformation #datastructures #help #planning #python #like #writing #productivity #analytics #datavisualization #datamanagement #references #database #change #email #success #testing #google #construction #management #management #building #people

--

--