https://github.com/aaryan-agr/book-recommendation-system
A Book Recommendation System that explores Content, Collaborative and Hybrid Filtering to recommend an ideal book for an user
https://github.com/aaryan-agr/book-recommendation-system
data-science deep-learning feature-engineering machine-learning predictive-analytics python recommendation-system
Last synced: 2 months ago
JSON representation
A Book Recommendation System that explores Content, Collaborative and Hybrid Filtering to recommend an ideal book for an user
- Host: GitHub
- URL: https://github.com/aaryan-agr/book-recommendation-system
- Owner: Aaryan-Agr
- Created: 2025-03-04T17:32:35.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-04T22:01:02.000Z (over 1 year ago)
- Last Synced: 2025-06-07T10:05:33.820Z (about 1 year ago)
- Topics: data-science, deep-learning, feature-engineering, machine-learning, predictive-analytics, python, recommendation-system
- Language: Jupyter Notebook
- Homepage:
- Size: 25.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ Book Recommendation System
## ๐ Overview
This project implements a **hybrid book recommendation system** that combines **content-based filtering** and **collaborative filtering** techniques. It processes book ratings and metadata to suggest books that a user might enjoy, leveraging both **machine learning models** and **data-driven insights**.
### ๐ Problem Statement
With the vast number of books available today, users often struggle to find relevant books based on their preferences. A **recommendation system** helps by analyzing book features and user interactions to generate personalized suggestions.
## ๐ Dataset
The project utilizes the **Book Recommendation Dataset** from Kaggle, which consists of: **Books.csv** (metadata such as title, author, publication year, and publisher), **Ratings.csv** (user ratings for books on a scale of 1 to 10), and **Users.csv** (demographic information about users).
## ๐ง Features and Methodology
### ๐งน 1. Data Cleaning & Preprocessing
**Handling Missing Values** by removing null values from metadata, **Feature Selection** by keeping only relevant columns such as title, author, and publication year, **Data Normalization** by converting book titles and authors to lowercase and removing spaces, **Filtering Active Users** who have rated at least **100 books**, and **Filtering Popular Books** with at least **25 ratings**.
### ๐ 2. Content-Based Filtering
**Text Preprocessing** involves tokenization using **NLTK**, stemming, and lemmatization. **Feature Engineering** combines book title, author, and publication year into a single **metadata vector** and applies **TF-IDF Vectorization** to convert text into numerical data. **Similarity Calculation** uses **cosine similarity** to compute distances between books and identify **top N similar books** to the input book.
### ๐ค 3. Collaborative Filtering
**User-Item Interaction Matrix** creates a pivot table where rows represent books, columns represent users, and values are ratings. **User-Based Recommendations** identify users with similar reading patterns. The **K-Nearest Neighbors (KNN) Algorithm** finds books rated similarly by other users and returns books with the highest **similarity scores**.
### ๐ 4. Hybrid Recommendation System
**Combines Content-Based and Collaborative Filtering** by assigning adjustable weights (`content_weight` and `collaborative_weight`), normalizing similarity scores, and generating **personalized hybrid recommendations**.
### ๐ 5. Evaluation & Performance Metrics
**Baseline Models** compare the hybrid method against **Global Mean Predictor** (predicts average rating for all books), **User Mean Predictor** (predicts using the average rating per user), and **Item Mean Predictor** (predicts using the average rating per book). **Root Mean Squared Error (RMSE)** is used to measure accuracy across different approaches.
## ๐ Installation & Setup
### Prerequisites
Ensure you have **Python 3.x** installed along with the required dependencies.
### ๐น Step 1: Install Dependencies
Run the following command:
```bash
pip install numpy pandas nltk scikit-learn kagglehub matplotlib
```
## ๐น Step 2: Download Dataset
The dataset is automatically fetched using `kagglehub`.
## ๐น Step 3: Run the Code
Execute the Jupyter Notebook or Python script to generate recommendations.
## ๐จ Usage
### ๐ข Content-Based Filtering
To get top 5 similar books based on metadata, use:
```python
contentFiltering(books, "1984",top_n=5)
```
### ๐ Hybrid Recommendations
To combine both approaches for a more accurate recommendation, use:
```python
hybrid_recommendations(
user_id=277427,
book_title="1984",
content_weight=0.5,
collaborative_weight=0.5,
num_recommendations=10
)
```
## ๐งช Evaluation
To compute RMSE scores for different recommendation models, use:
```python
compare_baseline(userItem, test_indices)
```
## ๐ Results
**The hybrid model improves recommendation accuracy** by leveraging both content similarity and user behavior.
**RMSE evaluation confirms** that the hybrid method outperforms individual approaches.
**User engagement is higher** due to personalized recommendations.
## ๐ ๏ธ Future Improvements
- **Implement deep learning models** for better predictions.
- **Integrate real-time user feedback** for dynamic recommendations.
- **Expand the dataset** with new book releases and user preferences.