for the full book experience, open on a laptop

ananya singh

hi everyone! i’m an undergrad studying computer science and artificial intelligence.

Photo collage

open to collaborators, internships, and research roles!

currently up to...

  1. exploring ai welfare research! we’re building increasingly complex systems that may or may not warrant moral consideration someday. i’m excited to dive into these questions.
  2. studying model preferences, especially towards rude users, by analyzing llm bail behaviour as a research assistant at padcomp lab!

recently...

  1. participated in apart research’s digital minds sprint! view submission →
  2. engaged in 8 weeks of discussions around x-risk, ai consciousness, what a better future looks like and more at nous ai safety x philosophy reading group!

experience

  1. research assistant ·

    studying model preferences, especially towards rude users, by analyzing llm bail behaviour

  2. tech & ops intern ·

    leading ai-native process improvements and supporting senior pms

    team photo outside bmo, 33 dundas street west
  3. junior full-stack developer co-op ·

    my first swe role where i built automations, fixed bugs, and shipped ui tools for the customer success team

leadership & volunteering

  1. president ·

    building pro bono tech for nonprofits and leading a 50+ person org

    sfu blueprint team on the beach
  2. host ·

    hosting weekly socratica co-working sessions for like-minded builders and creatives to find their third place

    treehouse team in front of the first spotlight screen
  3. vp finance ·

    managed a $60,000 budget and hosted residence events

glo was inspired by my daily struggles navigating the complex skincare world.

next page →

process

  • used design thinking to brainstorm and produce initial sketches
  • user interviews helped validate the problem
  • user surveys helped iteratively improve design
  • then i spent hours on figma producing the final high-fi prototype (almost gave myself carpal tunnel, pls use a mouse!)

results + next steps

  • got A+ in interactive prototype
  • got positive feedback from everyone around - seems like there's enough interest from people to use glo
  • might develop and publish glo on app store in the future!

← back

i asked myself: can machine learning discover my friendship patterns using 8 years of instagram dms? turns out it can - it found 5 groups of friendships in 400K+ messages across 1100+ people - pretty cool right!!!

the hackathon was hosted by SFU Data Science Student Society (DSSS) and SFU AIESEC as an opportunity for students to solve problems using a blend of data skills and business acumen.

DSSS hackathon team photo

next page →

process

  • data analysis (regression, funnel plot, descriptive statistics)
  • design thinking to prepare slides that stood out and communicated the story with impact
  • team brainstorming sessions for rapid problem solving
  • in-depth analysis of suggested solutions
  • discovered extra evidence through research to support claims

results

  • 2nd place amongst 15+ participating teams
  • positive feedback from judges and other teams directed at our creative slide deck
  • positive feedback from AIESEC exec team on proposed solutions

← back

← back to projects

machine learning my friendships

The Big Question

I have had my current Instagram account for over 8 years. For the major chunk of this time, I lived in India’s busiest and most social city, Mumbai, where the teen culture is such that Instagram becomes the main mode of socializing. For Mumbai teens, Instagram direct messages (DMs) are the western equivalent of text messages. Consequently, I accumulated a large library of DMs over the years, full of conversations and comments from people I met at every stage of my early life. Surely this rich dataset could tell us an interesting story with the right amount of data science. Hence, the question:

Can machine learning discover meaningful friendship patterns hidden in 8 years of digital conversations, and do these patterns match how we actually think about our relationships?

Data at a glance

  • 453,782 raw messages after cleaning
  • 1186 users after entity resolution
  • oldest to latest message: 2017-04-12 to 2025-07-16

Data Collection

Instagram allows data export via mobile app. After multiple attempts due to 4-day expiration limits and occasional incomplete downloads, I successfully obtained 8 years of message data.

Data Cleaning

I spent most of my time getting the data into a useful shape. The raw Instagram export contained over 540,000 messages across 1,200+ conversations, but required extensive preprocessing before analysis. Each conversation was stored as a separate folder containing multiple JSON files (message_1.json, message_2.json, etc.). Each file contained message metadata including sender names, timestamps, content, and call duration.

Major cleaning challenges

  • Filtering Conversations: I needed to distinguish between individual conversations and group chats. Using the “participants” field in each JSON file, I excluded any conversation with more than 2 participants to focus solely on one-on-one relationships.
  • System Message Removal: A significant portion of messages were system-generated notifications like “You started a video call,” or “Reacted ♥ to your message.” I used regex patterns to identify and remove these automated messages, keeping only real communication.
  • Data Standardization: Messages had inconsistent formats and some encoding issues. I converted all timestamps to datetime objects and since my analysis focused on communication patterns rather than content, I left encoding issues unresolved: I only needed message counts, timing, and metadata.
  • Entity Resolution: Many people had multiple Instagram accounts over the years, appearing as separate users in my data. I created a manual mapping system to merge conversations from the same person, combining their message counts and recalculating conversation timelines.

Feature Engineering

For each conversation, I calculated key friendship indicators: total messages exchanged, message frequency, conversation span, recency scores using exponential decay, communication balance ratios, and call duration totals. However, I ended up using only a few of these features based on how the clusters were forming.

Machine Learning Process (for the technical)

Why KMeans Clustering?

It was the intuitive choice to go with clustering since my data was unlabeled. K-means groups similar observations together, which fits the goal of finding friendship patterns. Since I expected a reasonable number of distinct friendship types (around 4-6), K-means with n_clusters=5 was appropriate.

Key preprocessing decisions

  • Log transformation of message counts: message counts were heavily right-skewed, with most conversations having few messages but some extreme outliers reaching thousands. The log transformation normalized this distribution.
  • Filtering threshold (>10 messages): conversations with very few messages represented brief encounters rather than meaningful relationships.
  • Feature selection: three key features captured different aspects of friendship: log_messages, recency_score, and conversation_span_days. To weight current communication patterns more heavily, I included recency_score three times in the feature list.

Cluster Discovery

I tried 4, 5, and 6 clusters: 5 gave the best balance without being too granular or losing important distinctions. When I looked at who ended up in each cluster, I could immediately tell what each group represented. The algorithm basically reads my mind about how I categorize my relationships.

Results (for the less technical)

My honest description of each group:

  • Best Friends: My closest friends I have made over the years. Total messages are high, and conversation spans are long.
  • Current Friends: High recency ratios, and this cluster is full of people I met after coming to SFU.
  • Old Friends: High message volume but low recency. The “we don’t talk anymore like we used to do” cluster.
  • Old Contacts: Low recency and low message volume. The “out of sight, out of mind” people.
  • Old Rare Contacts: Highest per day messages but everything else is the lowest. People I spoke to once or twice for very specific reasons.
Distribution of friendship levels

Plot 1: Distribution of Friendship Levels. 320 people are “Old Rare Contacts”: basically everyone you meet but don’t really connect with. Only 47 made it to “Best Friends.”

Friendship patterns scatter plot

Plot 2: Friendship Patterns. Best Friends sit alone in the top-right corner with high messages AND high recency. Old Friends vs Current Friends: similar message counts, totally different recency.

Friendship timeline

Plot 3: Friendship Timeline. Most 6-8 year relationships have flatlined, while my SFU friends cluster in the 0-2 year range with high activity. Geographic moves = friendship resets.

Communication intensity by cluster

Plot 4: Communication Intensity. Best Friends dominate with 4,000+ messages, but Old Friends (1,538) beat Current Friends (165): accumulated history counts.

Friendship characteristics heatmap

Plot 5: Friendship Characteristics Heatmap. Best Friends dominate every single metric. But Old Contacts have the highest messages per day rate: the “intense but brief” pattern. Recent doesn’t always mean deep.

Limitations

Entity resolution wasn’t exhaustive, so duplicates likely remain. I focused only on 1-on-1 conversations, missing group chat dynamics. The recency score weighting was subjective rather than optimized, and I had no external validation of friendship strength. Limiting to Instagram misses other communication channels like WhatsApp or calls.

Beyond Numbers

My biggest revelation? Recency bias is incredibly real. Despite having years of message history, recency_score became my most important feature, even more than total_messages or conversation_span_days.

Why? Because psychologically, I feel closer to someone I texted yesterday than someone I exchanged thousands of messages with two years ago. Our brains prioritize recent interactions over accumulated history.

This insight could have real applications. Instagram could use similar clustering to suggest “people you might want to reconnect with” by identifying Old Friends with high historical engagement but low recent activity.