A intelligent book recommendation web application built with Flask and machine learning. This system suggests similar books based on user input and displays the top 50 most popular books from a comprehensive dataset.
The Book Recommender System is designed to help users discover new books they might enjoy based on similarity analysis. It features two main sections:
- Home Page: Displays the top 50 most rated and voted books with book covers, titles, authors, vote counts, and ratings
- Recommendation Engine: Allows users to search for a book and receive personalized recommendations based on cosine similarity scores
-
Popular Books Showcase: Browse the top 50 most popular books with detailed information including:
- Book cover images
- Book titles
- Author names
- Number of votes/ratings
- Average rating scores
-
Intelligent Recommendations: Search for any book and receive 4 personalized book recommendations based on collaborative filtering using cosine similarity
-
Interactive Web Interface: Clean, user-friendly interface built with Bootstrap with a dark theme and green navigation bar
-
Fast Recommendations: Pre-computed similarity scores for instant book recommendations without model retraining
book_recommender_system/
โโโ app.py # Flask application with routes
โโโ book_recommender.ipynb # Jupyter notebook with model development
โโโ requirements.txt # Python dependencies
โโโ pyproject.toml # Project configuration
โโโ Procfile # Heroku deployment configuration
โโโ README.md # This file
โโโ model/ # Pre-trained model files
โ โโโ popular.pkl # Top 50 popular books dataset
โ โโโ pt.pkl # Pivot table for recommendations
โ โโโ books.pkl # Complete books dataset
โ โโโ similarity_scores.pkl # Pre-computed similarity matrix
โโโ templates/ # HTML templates
โโโ index.html # Home page with top books
โโโ recommend.html # Recommendation page
- Backend: Flask
- Data Processing: Pandas, NumPy
- Machine Learning: Cosine Similarity (Collaborative Filtering)
- Frontend: Bootstrap 3.7
- Data Serialization: Pickle
Flask
NumPy
Pandas
- Python 3.7 or higher
- pip (Python package manager)
- Clone or download the project:
cd book_recommender_system- Install dependencies:
pip install -r requirements.txt- Run the Flask application:
python app.py- Open your browser and navigate to:
http://127.0.0.1:5000/
Navigate to the home page to view the Top 50 Books dashboard:
The homepage displays:
- Book cover images in a card layout
- Book titles and authors
- Number of votes received
- Average rating scores
- Easy navigation to the recommendation engine
Click on "Recommend" in the navigation bar to access the recommendation engine:
How to use:
- Enter a book title in the search box
- Click the "Submit" button
- The system displays 4 recommended books similar to your search
- Recommendations are based on book similarity and user ratings
- Data Collection: The system uses a dataset containing books with their titles, authors, and user ratings
- Popular Books Selection: Identifies the top 50 most voted and rated books for homepage display
- Pivot Table Creation: Creates a user-book rating matrix for similarity computation
- Similarity Calculation: Computes cosine similarity scores between all books
- Recommendations: Returns the 4 most similar books (excluding the query book itself)
The recommendation engine uses Cosine Similarity with Collaborative Filtering:
- Cosine Similarity: Measures the angle between rating vectors, ignoring magnitude
- Collaborative Filtering: Based on the assumption that users who rated books similarly will enjoy the same books
- Pre-computed Scores: Similarity matrices are pre-calculated for instant recommendations
The model/ directory contains pre-trained pickle files:
| File | Purpose |
|---|---|
popular.pkl |
DataFrame of top 50 popular books |
pt.pkl |
Pivot table (books ร users) for similarity computation |
books.pkl |
Complete books dataset with metadata |
similarity_scores.pkl |
Pre-computed cosine similarity matrix |
- Description: Home page showing top 50 books
- Response: HTML page with book gallery
- Description: Recommendation search interface
- Response: HTML form for book search
- Description: Get recommendations for a book
- Parameters:
user_input(string): Book title to search
- Response: HTML page with 4 recommended books
- Responsive Design: Works on desktop and mobile devices (Bootstrap grid)
- Dark Theme: Black background with white text for better readability
- Color Scheme: Green navigation bar (#00a65a) and orange submit button
- Card Layout: Books displayed in responsive card components
- Image Integration: Book cover images loaded from URLs
- Instant Recommendations: Pre-computed similarity scores eliminate model inference delays
- Scalable Architecture: Pickle serialization allows quick loading of large datasets
- Lightweight: No heavy ML libraries required at runtime
- Efficient Search: Direct index lookup for user queries
- Local-First: Optimized for local development and usage
User Input (Book Title)
โ
Index Lookup in Pivot Table
โ
Retrieve Pre-computed Similarity Scores
โ
Sort by Similarity (descending)
โ
Select Top 4 Recommendations
โ
Fetch Book Details (title, author, image)
โ
Display to User
- Ensure the book title exists in the dataset
- Try searching with partial titles
- Check case sensitivity (though the system should handle this)
- Ensure all
.pklfiles are present in themodel/directory - Run the Jupyter notebook to regenerate model files if needed
- Change the port in
app.py:
app.run(debug=True, port=5001)The project uses a comprehensive book dataset containing:
- Thousands of unique books
- User ratings and votes
- Book metadata (title, author, ISBN)
- Book cover images
- User authentication and personalized recommendations
- Advanced filtering (genre, publication year, price range)
- User ratings and review system
- Content-based filtering using book descriptions
- Hybrid recommendation system combining multiple approaches
- Search autocomplete and suggestions
- Mobile app version
- Integration with library APIs
This project is open source and available for educational and commercial use.
Created as a book recommendation system for discovering similar books based on user preferences.
For issues or feature requests, please create an issue in the project repository.
Last Updated: January 2026

