GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com β€” GitHub - TechGenDM/Recommender-Systems: A rigorous, code-first curriculum for learning Recommender Systems β€” from collaborative filtering and latent factors to deep learning, retrieval, ranking, and responsible recommendation.

BranchesTags
Open more actions menu

Latest commit

 

History

19 Commits
19 Commits

Folders and files

NameName
Last commit message
Last commit date
projects
projects
 
 
1. Making recommendations.md
1. Making recommendations.md
 
 
10. Recommending from a Large Catalogue.md
10. Recommending from a Large Catalogue.md
 
 
11. Ethical Use of Recommender Systems.md
11. Ethical Use of Recommender Systems.md
 
 
12. TensorFlow Implementation of Content-Based Filtering.md
12. TensorFlow Implementation of Content-Based Filtering.md
 
 
13. Reducing the Number of Features.md
13. Reducing the Number of Features.md
 
 
14. PCA Algorithm.md
14. PCA Algorithm.md
 
 
15. PCA in Code.md
15. PCA in Code.md
 
 
2. Using Per-Item Features.md
2. Using Per-Item Features.md
 
 
3. Collaborative Filtering Algorithm.md
3. Collaborative Filtering Algorithm.md
 
 
4. Binary Labels: Favourites, Likes & Clicks.md
4. Binary Labels: Favourites, Likes & Clicks.md
 
 
5. Mean Normalization.md
5. Mean Normalization.md
 
 
6. TensorFlow Implementation of Collaborative Filtering.md
6. TensorFlow Implementation of Collaborative Filtering.md
 
 
7. Finding Related Items.md
7. Finding Related Items.md
 
 
8. Collaborative Filtering vs. Content-Based Filtering.md
8. Collaborative Filtering vs. Content-Based Filtering.md
 
 
9. Deep Learning for Content-Based Filtering.md
9. Deep Learning for Content-Based Filtering.md
 
 
README.md
README.md
 
 

Repository files navigation

🎯 Recommender Systems: From Mathematical Foundations to Deep Learning

GitHub Stars GitHub Forks License: MIT Python 3.10+ TensorFlow 2.x Status

A comprehensive, rigorous, and code-first open-access masterclass on Recommender Systems.
Designed for college students, software engineers, and machine learning practitioners seeking to master both the mathematical intuition and production-grade implementation of recommendation engines.


🌟 Philosophy & Pedagogical Approach

Modern recommendation engines power the world's most critical digital experiencesβ€”from Netflix and YouTube to Spotify, Amazon, and TikTok. However, learning materials often swing between high-level conceptual hand-waving and opaque, black-box library tutorials.

This curriculum follows a battle-tested 4-pillar pedagogical framework:

  1. Intuition First: Demystify why an algorithm works through geometric analogies and real-world scenarios before looking at code.
  2. Mathematical Rigor: Derive cost functions, gradients, vector projections, and latent representations step-by-step.
  3. From-Scratch & TensorFlow Implementation: Build algorithms end-to-end using standard numerical libraries and deep learning frameworks (tf.GradientTape, custom layers, and vector search).
  4. Systems & Ethics: Tackle scale (large catalogues, latency constraints, retrieval vs. ranking) and responsibility (algorithmic bias, filter bubbles, feedback loops).

πŸ—οΈ High-Level System Architecture

flowchart TD
    subgraph DataInput ["1. User & Item Data"]
        U["User Profiles & History<br/>(Likes, Clicks, Ratings)"]
        I["Item Catalogue & Metadata<br/>(Genres, Text, Features)"]
    end

    subgraph RetrievalStage ["2. Candidate Generation (Retrieval)"]
        CF["Collaborative Filtering<br/>(Matrix Factorization / Latent Factors)"]
        TT["Two-Tower Deep Models<br/>(User & Item Vector Embeddings)"]
        ANN["Approximate Nearest Neighbors<br/>(Vector Search: ScaNN / FAISS)"]
        U --> CF
        I --> CF
        U --> TT
        I --> TT
        CF --> ANN
        TT --> ANN
    end

    subgraph RankingStage ["3. Scoring & Ranking"]
        Ranker["Content-Based & Deep Rankers<br/>(Feature Crosses, Dense Networks)"]
        ANN -->|"Top ~100 Candidates"| Ranker
    end

    subgraph ServingStage ["4. Re-Ranking & Serving"]
        Ethical["Diversity, Deduplication & Ethical Guardrails<br/>(Filter Bubble Mitigation, Fair Exposure)"]
        Recs["Final Recommendations Feed<br/>(Top-K Delivered to User)"]
        Ranker --> Ethical
        Ethical --> Recs
    end
Loading

πŸ“š Complete Curriculum Roadmap

The modules below are ordered sequentially. Each topic builds directly on the theoretical and practical foundations laid by the previous chapters.

# Topic Key Concepts Focus Status
01 Making Recommendations Problem formulation, explicit vs. implicit feedback, recommendation matrix 🧠 Concept βœ… Completed
02 Using Per-Item Features Content-based linear regression, parameter optimization per user πŸ“ Math & Logic βœ… Completed
03 Collaborative Filtering Algorithm Joint optimization, latent factors $w^{(u)}$, $x^{(i)}$, simultaneous gradient descent πŸ“ Math & Algo βœ… Completed
04 Binary Labels: Favs, Likes, and Clicks Implicit feedback, logistic loss, binary cross-entropy formulation πŸ“ Formulation βœ… Completed
05 Mean Normalization Cold-start mitigation, unrated items, baseline offset adjustment πŸ’‘ Intuition βœ… Completed
06 TensorFlow Implementation of Collaborative Filtering Vectorization, tf.Variable, AutoDiff with tf.GradientTape, custom loss πŸ’» Code / TF βœ… Completed
07 Finding Related Items Latent space distance, Euclidean distance $|x^{(i)} - x^{(k)}|^2$, Cosine similarity πŸ“ Math & Logic βœ… Completed
08 Collaborative Filtering vs. Content-Based Filtering Comparative trade-off matrix, cold-start vulnerability, scaling properties βš–οΈ Analysis βœ… Completed
09 Deep Learning for Content-Based Filtering Two-tower neural architectures, user embeddings $v_u$, item embeddings $v_m$ 🧠 Deep Learning βœ… Completed
10 Recommending from a Large Catalogue Two-stage pipeline: Retrieval (Candidate Generation) + Ranking, Vector Indexing πŸš€ Scale & Sys βœ… Completed
11 Ethical Use of Recommender Systems Filter bubbles, engagement traps, algorithmic bias, fairness, transparency πŸ›‘οΈ Ethics βœ… Completed
12 TensorFlow Implementation of Content-Based Filtering Two-tower network in Keras/TF, dot-product output layer, evaluation πŸ’» Code / TF βœ… Completed
13 Reducing the Number of Features (Optional) High-dimensionality curse, compression, variance preservation intuition πŸ” Extension βœ… Completed
14 PCA Algorithm (Optional) Covariance matrix, projection, eigenvalue decomposition, singular value decomposition πŸ“ Math / Algo βœ… Completed
15 PCA in Code (Optional) From-scratch NumPy implementation, Scikit-Learn comparison, visualization πŸ’» Code βœ… Completed

πŸ“– Module-by-Module Detailed Breakdown

Phase 1: Problem Formulation & Feature-Driven Baselines

01. Making Recommendations

  • Intuition: Why recommendations are distinct from standard supervised classification and regression.
  • Formulation: The user-item interaction matrix $R$, where $r(i,j) = 1$ if user $j$ rated item $i$, and $y^{(i,j)}$ is the rating value.
  • Challenges: Sparsity (typically $&gt;99%$ sparse), scale, and the cold-start dilemma.

02. Using Per-Item Features

  • Concept: Leveraging item metadata $x^{(i)}$ (e.g., romance vs. action score) to learn personalized user preference vectors $w^{(j)}$ and bias $b^{(j)}$.
  • Model: Predicted rating $\hat{y}^{(i,j)} = w^{(j)} \cdot x^{(i)} + b^{(j)}$.
  • Cost Function: Regularized Mean Squared Error (MSE) optimized across rated items for each user independently.

Phase 2: Collaborative Filtering & Latent Factor Models

03. Collaborative Filtering Algorithm

  • The Core Breakthrough: What if we don't have explicit item features? We can learn user preferences $w^{(j)}$ and item features $x^{(i)}$ simultaneously.
  • Unified Objective Function: $$J(w, b, x) = \frac{1}{2} \sum_{(i,j): r(i,j)=1} \left( w^{(j)} \cdot x^{(i)} + b^{(j)} - y^{(i,j)} \right)^2 + \frac{\lambda}{2} \sum_{j=1}^{n_u} \sum_{k=1}^n (w_k^{(j)})^2 + \frac{\lambda}{2} \sum_{i=1}^{n_m} \sum_{k=1}^n (x_k^{(i)})^2$$
  • Optimization: Gradient updates alternating or running jointly over parameter tensors.

04. Binary Labels: Favs, Likes, and Clicks

  • Implicit Feedback Reality: Real-world platforms rarely collect 1-5 star ratings; interactions are binary (click, like, favorite, watch $&gt;30\text{s}$).
  • Probabilistic Formulation: Predicting $P(y^{(i,j)}=1) = g(w^{(j)} \cdot x^{(i)} + b^{(j)})$, where $g(z) = \frac{1}{1 + e^{-z}}$.
  • Loss Function: Binary Cross-Entropy applied to interaction signals.

05. Mean Normalization

  • The Cold-User Problem: For a new user with zero ratings, standard regularization shrinks $w^{(j)} \to 0$, predicting zero for everything.
  • Normalization Strategy: Subtract the mean rating $\mu_i$ for each item, train on normalized matrix, and predict $\hat{y}^{(i,j)} = w^{(j)} \cdot x^{(i)} + b^{(j)} + \mu_i$.
  • Outcome: A new user with no history is defaulted to average item ratings instead of zeros.

06. TensorFlow Implementation of Collaborative Filtering

  • Hands-on Lab: Building collaborative filtering from scratch in TensorFlow.
  • Core Techniques:
    • Vectorized loss computation using boolean masking (tf.gather_nd / element-wise multiplication).
    • Custom training loops using tf.GradientTape().
    • Gradient optimization with tf.keras.optimizers.Adam.

07. Finding Related Items

  • Geometric Latent Space: Once features $x^{(i)}$ are learned, items reside in an $n$-dimensional latent semantic space.
  • Similarity Metrics:
    • Squared distance: $|x^{(i)} - x^{(k)}|^2 = \sum_{l=1}^n (x_l^{(i)} - x_l^{(k)})^2$
    • Cosine similarity: $\cos(\theta) = \frac{x^{(i)} \cdot x^{(k)}}{|x^{(i)}| |x^{(k)}|}$
  • Use Cases: "Users who liked this also liked..." and automated playlist / related video carousels.

Phase 3: Content-Based Filtering & Modern Deep Architectures

08. Collaborative Filtering vs. Content-Based Filtering

  • Deep-Dive Comparative Analysis:
    • Collaborative Filtering: Discovers serendipitous items; struggles with cold start; doesn't require domain features.
    • Content-Based Filtering: Excellent cold-start handling for new items; transparent and explainable; struggles to recommend outside user's current niche.
  • Decision Matrix: When to choose which approach in production.

09. Deep Learning for Content-Based Filtering

  • Two-Tower Neural Network Architecture:
    • User Tower: Deep Feedforward Network mapping user features (demographics, interaction history, device) $\to$ embedding vector $v_u \in \mathbb{R}^d$.
    • Item Tower: Deep Feedforward Network mapping item features (title embeddings, category, age, tags) $\to$ embedding vector $v_m \in \mathbb{R}^d$.
  • Prediction: $\hat{y} = v_u \cdot v_m$.

10. Recommending from a Large Catalogue

  • The Production Bottleneck: Scoring millions of items with a neural network in real-time ($&lt;50\text{ms}$) is computationally infeasible.
  • The Two-Stage Industry Standard Pipeline:
    1. Candidate Retrieval (Candidate Generation): Filter millions down to hundreds using fast Approximate Nearest Neighbors (ANN) vector search (e.g., Google ScaNN, FAISS, HNSW).
    2. Scoring & Ranking: Pass the candidate subset through a fine-grained, compute-heavy deep ranker.

11. Ethical Use of Recommender Systems

  • Systemic Implications:
    • Filter Bubbles & Echo Chambers: Reinforcement feedback loops polarizing users.
    • Engagement vs. Well-being: Clickbait optimization vs. long-term user satisfaction.
    • Bias & Fairness: Popularity bias, demographic bias, and creator exposure fairness.
  • Mitigation Techniques: Exploration bonuses ($\epsilon$-greedy), diversification algorithms, and audit metrics.

12. TensorFlow Implementation of Content-Based Filtering

  • Hands-on Lab: Building and training a complete Two-Tower neural network in TensorFlow/Keras.
  • Components:
    • Multi-layer dense user tower and item tower with L2 normalization.
    • Custom Keras Model subclassing.
    • Fast inference simulation via vector dot product.

Phase 4: Dimensionality Reduction & Latent Space Mastery (Extension)

13. Reducing the Number of Features (Optional)

  • The Curse of Dimensionality: Why sparse, high-dimensional spaces degrade distance metrics and increase computational overhead.
  • Compression & Visualization: Projecting complex feature spaces down to 2D/3D for human interpretability.

14. PCA Algorithm (Optional)

  • Mathematical Foundation:
    • Feature normalization and zero-centering.
    • Covariance matrix calculation $\Sigma = \frac{1}{m} X^T X$.
    • Singular Value Decomposition (SVD) and Eigenvalue Decomposition.
    • Selecting principal components based on explained variance ratio.

15. PCA in Code (Optional)

  • Hands-on Lab:
    • Implementing PCA from scratch using pure NumPy (np.linalg.svd).
    • Validation against sklearn.decomposition.PCA.
    • Visualizing high-dimensional recommender item embeddings in 2D latent space.

πŸš€ Capstone & Portfolio Projects

Theory is only half the battle. To solidify your skills, explore the Projects Hub containing 5 production-grade capstone implementations:

  1. CineMatch: Vectorized Collaborative Filtering Engine from Scratch with AutoDiff & Mean Normalization (MovieLens 100K).
  2. ClickStream Rec: Implicit Feedback & Binary Cross-Entropy Recommender with Negative Sampling (E-Commerce Clickstream).
  3. StreamPulse: Two-Tower Deep Neural Network with Vector Search / ScaNN for Sub-10ms Large-Scale Retrieval (MovieLens 1M / Spotify).
  4. EmbeddingScope: Interactive 3D Latent Space & Item Similarity Visualizer using PCA Decomposition.
  5. FairRec: Algorithmic Bias Audit, Intra-List Diversity & Filter Bubble Mitigation Suite.

πŸ› οΈ Tech Stack & Environment Setup

To run the upcoming code labs and notebooks in this repository, set up your Python environment:

1. Clone the Repository

git clone https://github.com/TechGenDM/Recommender-Systems.git
cd Recommender-Systems

2. Create and Activate Virtual Environment

# macOS / Linux
python3 -m venv venv
source venv/bin/activate

# Windows
python -m venv venv
venv\Scripts\activate

3. Install Dependencies

pip install --upgrade pip
pip install tensorflow numpy pandas scikit-learn matplotlib seaborn jupyterlab

πŸ“ Repository Directory Structure

Recommender-Systems/
β”œβ”€β”€ README.md                                                  <- Curriculum & Repository Master Guide
β”œβ”€β”€ 1. Making recommendations.md                               <- Module 01: Formulation & Concepts
β”œβ”€β”€ 2. Using Per-Item Features.md                              <- Module 02: Content-Based Linear Baselines
β”œβ”€β”€ 3. Collaborative Filtering Algorithm.md                    <- Module 03: Joint Latent Factor Optimization
β”œβ”€β”€ 4. Binary Labels: Favourites, Likes & Clicks.md            <- Module 04: Implicit Feedback & Logistic Loss
β”œβ”€β”€ 5. Mean Normalization.md                                   <- Module 05: Cold-Start & Offsets
β”œβ”€β”€ 6. TensorFlow Implementation of Collaborative Filtering.md <- Module 06: AutoDiff & Custom Loops
β”œβ”€β”€ 7. Finding Related Items.md                                <- Module 07: Vector Distances & Cosine Sim
β”œβ”€β”€ 8. Collaborative Filtering vs. Content-Based Filtering.md  <- Module 08: Architecture Trade-Offs
β”œβ”€β”€ 9. Deep Learning for Content-Based Filtering.md            <- Module 09: Two-Tower Dual Encoders
β”œβ”€β”€ 10. Recommending from a Large Catalogue.md                 <- Module 10: Retrieval + Ranking Pipeline
β”œβ”€β”€ 11. Ethical Use of Recommender Systems.md                  <- Module 11: Fairness & Echo Chambers
β”œβ”€β”€ 12. TensorFlow Implementation of Content-Based Filtering.md<- Module 12: Keras Two-Tower Implementation
β”œβ”€β”€ 13. Reducing the Number of Features.md                     <- Module 13: Dimensionality Reduction
β”œβ”€β”€ 14. PCA Algorithm.md                                       <- Module 14: Mathematical PCA & SVD
β”œβ”€β”€ 15. PCA in Code.md                                         <- Module 15: Pure NumPy & Sklearn PCA
└── projects/                                                  <- Capstone Projects Hub
    β”œβ”€β”€ README.md                                              <- Project Specifications & Roadmap
    └── coming_soon.txt                                        <- Quick Reference Index

🀝 Contributing

Contributions, issues, and feature suggestions are welcome! Whether it's correcting a typo, proposing an intuitive diagram, or adding a state-of-the-art retrieval benchmark:

  1. Fork the Project.
  2. Create your Feature Branch (git checkout -b feature/AmazingInsight).
  3. Commit your Changes (git commit -m 'Add some AmazingInsight').
  4. Push to the Branch (git push origin feature/AmazingInsight).
  5. Open a Pull Request.

πŸ‘¨β€πŸ’» Author & Maintainer

Devasish Mishra

  • GitHub: @TechGenDM
  • Repository: TechGenDM/Recommender-Systems

πŸ“„ License

This repository is licensed under the MIT License - feel free to use this content for educational, research, and self-study purposes.

⭐ If you find this learning resource helpful, please consider starring the repository to support its reach!

About

A rigorous, code-first curriculum for learning Recommender Systems β€” from collaborative filtering and latent factors to deep learning, retrieval, ranking, and responsible recommendation.

Topics

collaborative-filteringcontent-based-filteringdeep-learninginformation-retrievalmachine-learningmachine-learning-educationml-engineeringpythonrecommendation-enginerecommender-systemtensorflowtwo-tower-models

Resources

Readme
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

You are visitor 01402775 β€” GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800Γ—600. No cookies required.