Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

Social network profiles and their analysis

How to represent user profiles in social networks, compute profile similarity and linkage, combine profile attributes with network structure (homophily/assortativity), and common analysis steps used by engineers.

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

Engineers use social network profiles and their analysis to match users across platforms, recommend friends or content, detect fake accounts, and measure how attributes (age, interest, location) shape network structure. Profile analysis is the bridge between raw user attributes and graph-based social analytics (see topics like homophily, assortativity, and link prediction).

Key ideas

All terms are defined before use.

  • Profile: the set of information fields (attributes) describing a social-network user on one platform. Examples: name, location, list of interests, education. A profile may be incomplete or noisy.

  • Attribute: a named property in a profile. An attribute can be categorical (one of a finite set, e.g., gender), numerical (e.g., age), or textual (free text, e.g., bio). Attributes may be single-valued or multi-valued (e.g., list of interests).

  • Profile vector: a numeric vector representation of a profile suitable for mathematical comparison. Construction methods: binary indicator over possible attribute values, frequency counts, TF–IDF for text, or normalized numeric scaling. Always state the encoding used.

  • Profile similarity: a real number quantifying how close two profiles are. Common measures: Jaccard similarity for sets, Cosine similarity for vectors, Dice coefficient, Euclidean distance (a distance; smaller means more similar), and string edit distances (e.g., Levenshtein distance) for textual fields. For record linkage and matching, combine field-level similarities into a composite score (weighted sum, logistic model, or learned classifier).

  • Blocking (or indexing): a pre-filtering step in record linkage that groups candidate pairs to reduce comparisons. Example rule: only compare users with the same normalized city or same email domain.

  • Record linkage (profile linkage): the task of deciding whether two profiles (possibly from different platforms) belong to the same real person. It uses attribute similarity, blocking, and decision rules/classifiers.

  • Homophily: the tendency of nodes with similar attributes to connect. Quantified using assortativity.

  • Assortativity (attribute assortativity coefficient): a normalized measure of preference for nodes to attach to others that are similar in a categorical attribute. For a categorical attribute partitioning nodes into types, we create a mixing matrix e where e_ij is the fraction of edges between type i and type j (undirected: symmetric). Then assortativity r is defined as r = (sum_i e_ii - sum_i a_i b_i) / (1 - sum_i a_i b_i) where a_i = sum_j e_ij and b_j = sum_i e_ij (for undirected graphs a_i = b_i). r ∈ [-1,1], with r>0 indicating assortative mixing (homophily). For numeric/scalar attributes, assortativity is defined as the Pearson correlation of attribute values across edge endpoints.

  • Privacy considerations: Profiles carry personally identifying information. Linking profiles across networks raises privacy risks. Engineers must follow legal and ethical constraints and consider differential privacy or anonymization when studying profiles.

Diagrams to draw in an exam answer (describe exactly):

  • Diagram 1 (ego profile + network): Draw a central circle labeled "Ego (User A)" connected by straight lines to 5 smaller circles (neighbors). Next to the ego, list attributes (age: 24, city: Pune, interests: {music, coding}). Label one neighbor as "B (age 25, city: Pune, interests: {music, cricket})" to show attribute overlap.
  • Diagram 2 (bipartite profile graph): Draw left side as user nodes U1..U4, right side as attribute nodes (music, coding, sports). Draw edges from users to attributes they have. This shows a user→attribute bipartite representation used for computing shared interests.

Exact assumptions you must state in answers: whether attributes are complete, whether vectors are normalized, whether edges are directed, and whether attribute comparisons are case-sensitive or preprocessed (lowercased / trimmed).

Formulas

J(A,B) = |A ∩ B| / |A ∪ B| where A,B are sets of values (no units). Applies to set-valued attributes (e.g., interests).

cos(u,v) = (u · v) / (||u|| * ||v||) where u,v are real vectors, · is dot product, ||u|| is Euclidean norm (no units). For non-negative vectors (e.g., TF–IDF) cos ∈ [0,1].

Dice(A,B) = 2|A ∩ B| / (|A| + |B|) for sets A,B.

edit(a,b) = minimum number of insertions, deletions, substitutions to transform string a to b (Levenshtein distance; integer count).

composite_score = Σ_i w_i * s_i where s_i is field-level similarity (normalized to [0,1]), w_i ≥ 0 are weights, commonly normalized so that Σ_i w_i = 1 (dimensionless). Applies when combining multiple attribute similarities.

precision = TP / (TP + FP) recall = TP / (TP + FN) where TP/FP/FN are counts of true/false positives/negatives in linkage or classification evaluation (no units). F1 = 2 * precision * recall / (precision + recall).

assortativity r = (Σ_i e_ii - Σ_i a_i b_i) / (1 - Σ_i a_i b_i) where e_ij is fraction of edges between type i and type j, a_i = Σ_j e_ij, b_j = Σ_i e_ij. r is unitless and in [-1,1]. For numeric/scalar attributes, r is the Pearson correlation between the attribute values at the two ends of edges: r = (Σ_e (x_u - x̄)(x_v - ȳ)) / sqrt(Σ_e (x_u - x̄)^2 Σ_e (x_v - ȳ)^2) (for undirected graphs x̄ = ȳ).

Note: For undirected graphs, e is symmetric and a_i = b_i.

Worked examples

Example 1 — numeric: Jaccard and Cosine for interest lists Problem statement: Two user profiles have interest lists:

  • User A: {music, cricket, coding, movies}
  • User B: {music, tennis, coding, travel} Steps:
  1. Compute Jaccard: A ∩ B = {music, coding} so |A ∩ B| = 2. A ∪ B has 6 elements, so J = 2/6. Formula: J(A,B) = |A∩B|/|A∪B| → numbers: 2 / 6 = 0.333...
  2. Represent binary vectors over union order [music, cricket, coding, movies, tennis, travel]: u = [1,1,1,1,0,0], v = [1,0,1,0,1,1] Dot product u·v = 11 + 10 + 11 + 10 + 01 + 01 = 2 Norms: ||u|| = sqrt(4) = 2, ||v|| = sqrt(4) = 2 Cosine = 2 / (2*2) = 0.5 Final answers: Jaccard = 0.333... (≈0.333), Cosine = 0.5.

Example 2 — model-answer theory: Linking profiles across two platforms Question: Describe a pipeline to decide whether a pair of profiles from different social networks refer to the same person, and how to evaluate it. Model answer (condensed but complete):

  1. Preprocessing: normalize textual fields (lowercase, remove punctuation), unify date formats, canonicalize locations (city names). State assumptions about availability and missing values.
  2. Blocking: apply one or more blocking rules to reduce candidate pairs. Example blocks: same email username, same phone country code plus first name initial, or same city and at least one shared interest. Justify blocks by precision/recall trade-off.
  3. Field-level similarity: compute per-attribute similarities: edit distance-based normalized similarity for names, exact match or fuzzy match for emails, Jaccard for multi-valued interests, cosine for TF–IDF vectors of bios, numeric difference normalized for ages.
  4. Combine similarities: use a weighted linear combination or a trained classifier (logistic regression, random forest) built from labeled pairs. Show formula: score = Σ_i w_i * s_i and explain training to learn w_i.
  5. Decision threshold: choose threshold on score based on ROC curve or maximize F1 depending on application (precision-critical vs recall-critical).
  6. Evaluation: compute precision, recall, F1 on a held-out labeled test set. Report confusion counts TP, FP, FN, TN and show chosen operating point.
  7. Error analysis and privacy: inspect false matches and misses; consider privacy and legal constraints in linking. A full-mark answer explicitly states assumptions, shows sample similarity computations, explains blocking rationale, and includes evaluation metrics.

Common mistakes

  • Forgetting to state whether graph edges are directed when computing assortativity or mixing matrices.
  • Comparing every pair of profiles without blocking, causing infeasible O(n^2) work.
  • Combining unnormalized field similarities (different scales) without rescaling to a common range.
  • Confusing Jaccard and Dice; both measure overlap but use different denominators.
  • Not handling missing values (e.g., treating missing as zero vs ignoring the field).

For your exam

Typical question types:

  • Definitions: define profile, attribute, homophily, blocking.
  • Short notes: compare Jaccard, Cosine, and Dice; explain blocking methods.
  • Derivations: show that cosine = (u·v)/(|u||v|) and explain its geometric meaning (angle between vectors).
  • Numericals: compute Jaccard/cosine on small examples (show vectors and norms), compute precision/recall from counts.
  • Diagrams: draw an ego network and label attributes, or draw a bipartite user–attribute graph.
  • Applied theory: outline a pipeline for profile linkage and show evaluation metrics.

What a full-marks answer includes:

  • Clear definitions of every term used.
  • Statement of assumptions (missing values, directed/undirected graph, normalization).
  • Correct formulas with symbols explained.
  • For numeric problems: show each calculation step with numbers and units (if any), and final answers highlighted.
  • For pipelines: justify choices (blocking rules, similarity measures, classifier) and show how to evaluate.

Quick check

  1. Give the formula for Jaccard similarity between two sets A and B.
  2. What is the cosine similarity of u=[1,0,1] and v=[1,1,0]?
  3. What is blocking in record linkage?

Answers: 1) J(A,B)=|A∩B|/|A∪B|. 2) cos = (11 + 01 + 1*0) / (sqrt(2)*sqrt(2)) = 1/2 = 0.5. 3) Blocking is a pre-filtering step that groups candidate profile pairs to reduce comparisons (e.g., same city or same email domain).

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?