Skip to content

HarshitaSobhani/InstagramRecSys

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Instagram Account Recommendation System

30-second pitch: A hybrid recommender that suggests Instagram accounts to follow, blending content-based filtering (TF-IDF over account descriptions) with user-user collaborative filtering (KNN over a follow-graph), tuned via a leave-one-out evaluation and explored through an interactive Streamlit dashboard.

Problem

Recommending accounts to follow is a cold-start-heavy variant of the classic recsys problem: new users have almost no follow history, and "similar users" is a weaker signal than in, say, product recommendations, because interest overlap on social platforms is diffuse. This project explores whether blending two complementary signals (what an account is about, vs. who else follows it) beats either alone.

Approach

  1. Synthetic follow-graph (dataset.py) — 60 hand-authored accounts across 6 categories (tech, travel, fitness, food, fashion, music), each with a short text description. 50 synthetic users are generated with 1–2 "primary" interest categories; each user follows 3–12 accounts, drawn 75% from their primary categories and 25% at random, seeded for reproducibility.
  2. Content-based filtering (content_based.py) — TF-IDF vectorizes account descriptions; a user profile is the centroid of their followed accounts' vectors; candidates are ranked by cosine similarity to that profile.
  3. Collaborative filtering (collaborative.py) — builds a user-account interaction matrix, finds the K=10 nearest users by cosine similarity, and aggregates their follows into a score.
  4. Hybrid engine (engine.py) — both sub-scores are min-max normalized to [0, 1], then combined as score = α·CB + (1-α)·CF (default α=0.5, adjustable live in the dashboard).
  5. Evaluation (engine.py::evaluate_recommender) — leave-one-out: for each user, hide one followed account, rebuild recommendations on the rest, and check whether the hidden account reappears in the top-K.
  6. Dashboard (app.py) — Streamlit UI to pick a user, tune α and top-N live, and view heatmaps/graphs of the recommendations.

Tradeoffs

  • Weighted-sum hybrid over a learned blend: a static α is simple and fully interpretable in a live demo, at the cost of not adapting per-user (e.g. giving CF more weight to users with denser follow histories). A learned or per-user α is the natural next step, not implemented here.
  • Min-max normalization over z-score: chosen for simplicity and bounded [0,1] output that's easy to blend and display; more sensitive to outlier scores than z-score would be.
  • K=10 neighbors, fixed: not tuned via grid search against the eval metric — picked as a reasonable default for a 50-user graph.

Dataset — and its limitations

The dataset is entirely synthetic, not real Instagram data (no API access was used or sought). 60 accounts and their descriptions were hand-written to be realistic per category; 50 users and their follow-graphs are generated by a deterministic, category-biased random process (seed=42). This means:

  • The results below measure whether the hybrid algorithm can recover the generator's own category-bias structure — they say nothing about real user behavior, real account descriptions, or real engagement signals.
  • There is no true cold-start test (every synthetic user already has 3+ follows) and no temporal signal (no "when" a follow happened).
  • Category boundaries are clean by construction; real interests overlap and drift in ways this data can't represent.

Results

Leave-one-out evaluation, k=5, α=0.5, 50 users:

  • Hit rate@5: 44% — the hidden follow appears in the top-5 recommendations in roughly 4 of 9 trials.
  • Precision@5 and Recall@5 are reported per-trial in engine.py's eval output (see results DataFrame); no aggregate benchmark file is checked in — run python engine.py to reproduce.

Read this as a sanity check that the hybrid approach recovers synthetic category-affinity signal, not as evidence it would perform well on real Instagram data. A 44% hit rate on a 60-item, 6-category synthetic catalog is a much easier task than recommending among millions of real accounts with noisy, overlapping interests.

How to run

git clone https://github.com/HarshitaSobhani/InstagramRecSys.git
cd InstagramRecSys/instagram-recsys
pip install -r requirements.txt

# CLI demo + evaluation
python engine.py

# Interactive dashboard
streamlit run app.py

Structure

instagram-recsys/
├── dataset.py        # synthetic account catalog + follow-graph generator
├── content_based.py  # TF-IDF + cosine similarity recommender
├── collaborative.py  # user-user KNN recommender
├── engine.py          # hybrid blend + leave-one-out evaluation
├── visualize.py       # heatmaps, radial recommendation graph
└── app.py             # Streamlit dashboard

About

A hybrid recommendation system that suggests Instagram accounts based on user interests using both content-based filtering and collaborative filtering techniques. The project includes a fully interactive Streamlit dashboard for real-time exploration and visualization of recommendations.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages