GitHub Repository: Recommendation-Engine
This project implements a comprehensive Movie Recommendation System using seven different methods, designed to provide movie suggestions either based on a selected movie or through user interaction data. The algorithms used in this project are:
- K-Nearest Neighbors (KNN)
- Gaussian Mixture Models (GMM)
- Content-Based Filtering
- Clustering (K-Means)
- Support Vector Machines (SVM)
- Artificial Neural Networks (ANN)
- Bayesian Recommendation Method
Each method is implemented independently and demonstrates a unique approach to personalization and filtering of movie content.
The preprocessing pipeline of the movie recommendation system involved the following steps:
- Original dataset contained
$24$ columns and more than$700,!000$ rows.
- Removed all rows or entries with missing/null values.
Let:
-
$D$ be the original dataset. -
$D_{\text{cleaned}}$ be the dataset after cleaning nulls.
Then: $$ D_{\text{cleaned}} = D \setminus { \text{rows with nulls} } $$
- To reduce computational load, kept only the top
$5000$ rows.
Let:
-
$D_{\text{sampled}}$ be the dataset after sampling.
Then: $$ D_{\text{sampled}} = \text{Top } 5000 \text{ rows of } D_{\text{cleaned}} $$
- Converted categorical data (e.g., genres, tags) to binary vector format.
For a feature with
- Dropped categorical columns with too few entries (low cardinality).
- Applied TF-IDF vectorization to string data (e.g., overview, tagline).
Let:
-
$tf(t,d)$ = term frequency of term$t$ in document$d$ -
$idf(t)$ = inverse document frequency of term$t$
Then: $$ \text{TF-IDF}(t,d) = tf(t,d) \cdot \log\left( \frac{N}{df(t)} \right) $$
Where:
-
$N$ is the total number of documents -
$df(t)$ is the number of documents containing term$t$ -
Dropped textual columns with insufficient data.
- After all transformations, each movie is represented as a vector of
$800$ dimensions:
These vectors are then used as input for all recommendation algorithms.

Given:
- A movie query vector
$q$ - A set of movie vectors
$x_1, x_2, ..., x_n$
We compute the Euclidean distance:
We then select the
Alternatively, cosine similarity can be used:
Purpose: Probabilistic clustering of movies based on their features and recommending from similar distributions.
GMM assumes data points are generated from a mixture of several Gaussian distributions:
Where:
-
$\pi_k$ = weight of the$k^{\text{th}}$ component -
$\mu_k$ = mean of the$k^{\text{th}}$ component -
$\Sigma_k$ = covariance matrix of the$k^{\text{th}}$ component -
$\mathcal{N}(x|\mu_k,\Sigma_k)$ = multivariate normal distribution

Content features are typically vectorized using TF-IDF or embeddings. Then similarity is measured using cosine similarity:
Recommendations are sorted by similarity score.
Group similar movies together based on features. This enables the system to recommend movies from the same cluster, assuming that users might enjoy other items within a group of similar ones.
K-Means aims to partition n data points into k clusters in which each data point belongs to the cluster with the nearest mean (centroid), minimizing intra-cluster variance.
- Choose the number of clusters (k)
- Randomly initialize k centroids
- Assign each point to the nearest cluster centroid
- Recalculate cluster centroids as the mean of assigned points
- Repeat steps 3-4 until convergence (or until reach max epoch)
After clustering movies:
- For a given user’s liked movie, find the cluster it belongs to
- Recommend other movies from the same cluster
This helps in:
- Discovering niche patterns in data
- Making content-based or collaborative recommendations more effective
Purpose: Classify user-preferred genres or features to recommend movies falling within the same classification boundaries.
SVM aims to find a hyperplane:
Where:
-
$\mathbf{w}$ = weight vector -
$b$ = bias -
$\mathbf{x}_i$ = feature vector of movie -
$y_i$ = user label (+1 for like, -1 for dislike)
With kernels:
Purpose: Learn from user interactions (ratings, clicks, etc.) to recommend personalized content.
A basic feedforward ANN:
Layer Transformations:
Loss Function (Cross-Entropy):
Backpropagation Update:
Where:
-
$\alpha$ is the learning rate -
$\hat{y}_i$ is predicted probability

Using Bayes’ Theorem:
Let:
-
$M$ be a movie -
$U$ be user preferences
Then:
With Naive Bayes:
Where
We utilized the following for preprocessing and feature engineering:
- Movie Metadata: genres, tags, cast, director
- User Interaction Data: ratings, watch history, favorites
- Textual Features:
- Cleaned and lowercased text
- Removed stopwords and punctuations
- Tokenized, then used TF-IDF vectorization
- Numerical Features:
- Normalization using min-max scaling
- PCA for dimensionality reduction
- Categorical Features:
- One-hot encoding for genres, directors, and cast
| Method | Type | User Input Based | Model Type | Strengths | Weaknesses |
|---|---|---|---|---|---|
| KNN | Unsupervised | No | Memory-based | Simple, no training | Inefficient at scale |
| GMM | Unsupervised | No | Probabilistic | Soft clustering | Sensitive to parameters |
| Content-Based | Unsupervised | No | Metadata-based | No cold-start issue for users | Limited diversity |
| K-Means Clustering | Unsupervised | No | Hard clustering | Fast and scalable | Assumes spherical clusters |
| SVM | Supervised | No | Classification | Works with high-dimensional data | Needs labeled data |
| ANN | Supervised | Yes | Deep learning | Captures nonlinear relationships | Needs large dataset |
| Bayesian | Probabilistic | No | Probabilistic | Works well with sparse data | Assumes independence of features |
- Implement hybrid recommender systems combining collaborative + content-based filtering
- Use Transformer-based architectures for sequence-aware recommendations
- Incorporate temporal dynamics and trends in user behavior
- Deploy on cloud with scalable APIs and dashboards
- Python
- NumPy, Pandas
- Scikit-learn
- TensorFlow / PyTorch
- Matplotlib / Seaborn











