This project implements a deep learning-based recommender system using the MovieLens 100K dataset. The system explores both collaborative filtering and content-based filtering approaches, powered by deep learning models. Three different models were implemented and evaluated: Neural Matrix Factorization (NeuMF), LSTM-based sequential recommender, and a content-based neural network model. The models were evaluated using various metrics including RMSE, MAE, Precision@k, Recall@k, and NDCG@k. The LSTM model achieved the best performance in terms of RMSE (0.9907), while the NeuMF model had the lowest MAE (0.7836). A hybrid recommendation approach was also proposed to combine the strengths of both collaborative and content-based filtering.
Recommender systems are essential tools in today's digital landscape, helping users discover relevant content in an increasingly vast sea of options. These systems analyze user behavior and preferences to suggest items that users might find interesting or useful. Deep learning has emerged as a powerful approach for building recommender systems, offering improved accuracy and the ability to capture complex patterns in user-item interactions.
This project implements and evaluates several deep learning-based recommender system approaches using the MovieLens 100K dataset, which contains 100,000 ratings from 943 users on 1,682 movies. The project explores both collaborative filtering (which focuses on user-item interactions) and content-based filtering (which leverages item features), as well as a hybrid approach that combines both methods.
The MovieLens 100K dataset was used for this project. This dataset contains:
- 100,000 ratings (1-5) from 943 users on 1,682 movies
- Each user has rated at least 20 movies
- Simple demographic information for the users (age, gender, occupation, zip code)
- Movie information including title, release date, and genre
The dataset was split into training (80%) and testing (20%) sets for model evaluation.
The data preparation process involved:
- Loading the MovieLens 100K dataset
- Encoding user and movie IDs
- Splitting data into training and testing sets
- Extracting and processing movie features (particularly genres)
- Creating PyTorch Dataset classes for both collaborative and content-based approaches
Two collaborative filtering models were implemented:
-
Neural Matrix Factorization (NeuMF):
- Combines the linearity of Matrix Factorization with the non-linearity of Neural Networks
- Consists of two parallel components: Generalized Matrix Factorization (GMF) and Multi-Layer Perceptron (MLP)
- The outputs of these components are concatenated and fed into the final output layer
-
LSTM-based Sequential Recommender:
- Treats user ratings as sequences to capture temporal patterns in user preferences
- Uses LSTM layers to process sequences of movie ratings
- Combines the LSTM output with target movie embeddings to predict ratings
The content-based filtering approach leveraged movie genre information:
-
Similarity-Based Recommendations:
- Created TF-IDF vectors for movie genre strings
- Computed cosine similarity between movies based on their genre features
- Implemented a function to recommend similar movies based on content similarity
-
Neural Network for Content-Based Filtering:
- Combines user embeddings with movie genre features
- Processes genre features through fully connected layers
- Concatenates user and genre embeddings for final prediction
A hybrid recommendation function was proposed to combine the strengths of both collaborative and content-based approaches. This function would take predictions from both types of models and combine them using a weighted average, with the weight determined by a parameter alpha.
The project was implemented using PyTorch, a popular deep learning framework. Key implementation details include:
- Embeddings: 50-dimensional embeddings were used for users and movies
- Neural Network Architectures:
- NeuMF: GMF and MLP components with layers [64, 32, 16, 8]
- LSTM: 2-layer LSTM with hidden dimension 64, followed by fully connected layers
- Content-Based: Fully connected layers for genre feature processing and prediction
- Loss Function: Mean Squared Error (MSE)
- Optimizer: Adam with learning rate 0.001 and weight decay for regularization
- Training: 10 epochs for each model with batch sizes of 256 (NeuMF, Content-Based) and 64 (LSTM)
The models were evaluated using Root Mean Square Error (RMSE) and Mean Absolute Error (MAE):
| Model | RMSE | MAE |
|---|---|---|
| NeuMF | 1.0013 | 0.7836 |
| LSTM | 0.9907 | 0.7835 |
| Content-Based | 0.9984 | 0.7971 |
The LSTM model achieved the best RMSE, while the NeuMF model had the lowest MAE (by a small margin).
The models were also evaluated using ranking metrics at different k values:
| Model | Precision@10 | Recall@10 | NDCG@10 |
|---|---|---|---|
| Random | 0.0073 | 0.0058 | 0.0078 |
| Popular | 0.0717 | 0.0916 | 0.0996 |
| NeuMF | 0.0082 | 0.0070 | 0.0094 |
| LSTM | 0.0101 | 0.0065 | 0.0107 |
| Content-Based | 0.0108 | 0.0099 | 0.0129 |
Interestingly, the popularity-based baseline performed well on ranking metrics, suggesting that popular items are often relevant to many users. Among our implemented models, the content-based approach showed strong performance on ranking metrics, particularly for Precision@10 and NDCG@10.
Based on the evaluation results, several insights can be drawn:
-
Model Performance:
- The LSTM model's strong performance in terms of RMSE suggests that sequential patterns in user behavior are important for recommendation quality.
- The NeuMF model provides a good balance between error metrics and ranking performance.
- The Content-Based model, while slightly behind in error metrics, shows competitive performance on ranking metrics, indicating that genre information is valuable for recommendations.
-
Comparison with Baselines:
- All implemented models significantly outperform the random baseline, demonstrating the value of the deep learning approaches.
- The popularity-based baseline performs surprisingly well on ranking metrics, highlighting the importance of considering popular items in recommendations.
-
Complementary Strengths:
- The collaborative filtering models (NeuMF and LSTM) excel at capturing user-item interactions and preferences.
- The content-based model leverages item features (genres) to make recommendations, which can be particularly useful for new items with limited interaction data.
- A hybrid approach could combine these complementary strengths for improved recommendations.
-
Practical Implications:
- The choice of model depends on the specific application and evaluation metrics of interest.
- For applications where rating prediction accuracy is paramount, the LSTM model would be preferred.
- For applications focused on ranking quality, a hybrid approach combining collaborative and content-based methods might be optimal.
While the implemented models show promising results, several limitations and areas for future improvement can be identified:
-
Cold Start Problem:
- The current models may struggle with new users or items with limited interaction data.
- Future work could explore techniques to address the cold start problem, such as incorporating additional user and item features.
-
Model Complexity:
- The deep learning models have many parameters and may be computationally expensive to train and deploy.
- Future work could explore more efficient architectures or techniques like knowledge distillation.
-
Additional Features:
- The current implementation primarily uses ratings and genre information.
- Future work could incorporate additional features such as user demographics, movie descriptions, or temporal information.
-
Hybrid Approach:
- The current hybrid approach is a simple weighted average of model predictions.
- Future work could explore more sophisticated hybrid methods, such as learning the optimal combination weights or using a meta-model.
-
Evaluation:
- The current evaluation focuses on offline metrics.
- Future work could include online evaluation through A/B testing or user studies to assess real-world performance.
This project successfully implemented and evaluated three deep learning-based recommender system approaches: Neural Matrix Factorization (NeuMF), LSTM-based sequential recommendation, and content-based filtering. The models were evaluated using various metrics, with the LSTM model achieving the best RMSE and the content-based model showing strong performance on ranking metrics.
The results highlight the complementary strengths of collaborative and content-based filtering approaches, suggesting that a hybrid approach could provide the best overall performance. The project demonstrates the potential of deep learning for building effective recommender systems and provides a foundation for future work in this area.
-
MovieLens Dataset: https://grouplens.org/datasets/movielens/
-
PyTorch Documentation: https://pytorch.org/docs/stable/index.html