This is a book recommendation system built using collaborative filtering techniques. The system recommends books based on user ratings and the similarity between either books (item-item filtering) or users (user-user filtering).
- About
- Features
- Technologies
- Data Sources
- Installation
- Usage
- Files and Folders
- How It Works
- Future Enhancements
- Contributing
- License
This project implements a book recommendation system that provides personalized recommendations to users based on their historical ratings. Collaborative filtering, a popular recommendation algorithm, is used to make predictions by analyzing user-item interactions.
- Personalized recommendations based on collaborative filtering (User-User & Item-Item)
- Popular books display on the homepage
- Ability to search for recommendations by entering a book name
- Flask web application with a user-friendly interface
- Preprocessed data and fast loading using
.pklfiles for efficient performance
This project uses the following tools and technologies:
- Python: Core programming language
- Flask: For building the web application
- Pandas: For data manipulation
- Numpy: For numerical operations
- Pickle: For saving and loading preprocessed data
- Jinja2: For HTML templating
- Bootstrap: For styling the front-end pages
- Books.csv: Contains book metadata such as book ID, title, author, etc.
- Users.csv: Contains information about users.
- Ratings.csv: Contains user ratings for different books.
These CSV files are processed and saved into .pkl files for efficient data access within the web application.
git clone https://github.com/HimanshiVerma05/BookRecommenderSystem.git
cd book-recommender-systempython -m venv venv
# For Windows
venv\Scripts\activate
# For macOS/Linux
source venv/bin/activateInstall the dependencies listed in the requirements.txt file:
pip install -r requirements.txtIf you're running the Flask app locally, set the Flask environment variable:
# For Windows
set FLASK_APP=app.py
# For macOS/Linux
export FLASK_APP=app.pyRun the Flask application locally:
flask runOpen your browser and go to http://127.0.0.1:5000/ to interact with the recommendation system.
- Home Page: The homepage displays the top 50 most popular books, which are precomputed and loaded from
popular.pkl. - Recommendation Page: Navigate to the "Recommend" page, input the name of a book, and receive personalized recommendations.
- Backend: The backend loads preprocessed data (books, ratings, similarity scores) from
.pklfiles to generate recommendations.
- app.py: Main Python file that defines the Flask routes and loads data from
.pklfiles. - templates/: Contains the HTML templates (index.html and recommend.html) for rendering the UI using Jinja2.
index.html: Displays the top 50 books.recommend.html: Allows users to search for book recommendations.
- static/: Folder for static assets like CSS, images, etc.
- Books.csv, Ratings.csv, Users.csv: Raw data files used for building the recommendation system.
- books.pkl, similarity_scores.pkl, pt.pkl: Preprocessed data files for faster loading and recommendation generation.
- requirements.txt: Contains the list of dependencies required to run the project.
-
Data Preprocessing: The book, user, and rating data are loaded from CSV files and cleaned. Missing values are handled, and similarity scores are computed based on user-item interactions.
-
Collaborative Filtering:
- User-User Collaborative Filtering: Recommends books to a user based on the similarity to other users' preferences.
- Item-Item Collaborative Filtering: Recommends similar books based on the similarity between books (e.g., books rated highly by the same users).
-
Pickle Serialization: The preprocessed data (books, ratings, and similarity scores) are saved in
.pklfiles to avoid reprocessing the data each time the app is run. -
Flask Web Application: The Flask app serves two primary pages: the homepage showing popular books and the recommendation page, where users can input a book and get recommendations.
- Add support for content-based filtering.
- Integrate a user login system to track individual users' reading histories.
- Improve the recommendation algorithm with hybrid filtering (combining collaborative filtering with content-based techniques).
- Add more dynamic user interaction features, such as rating or reviewing books directly in the app.
- Special thanks to Campusx tutorial - https://www.youtube.com/watch?v=1YoD0fg3_EM
- Dataset from - https://www.kaggle.com/datasets/arashnic/book-recommendation-dataset