A clean, easy-to-understand book recommendation system perfect for explaining in interviews and presentations.
This system recommends books based on similarity using:
- Content-Based Filtering: Finds books similar to ones you like
- TF-IDF Vectorization: Converts book information to numbers
- Cosine Similarity: Measures how similar books are
- Fuzzy Matching: Handles typos in book titles
pip install -r requirements.txt# Command line version
python books.py
# For WebServer
python app.py
# Then open: http://localhost:5000- Loads book data from CSV file
- Cleans and prepares the data
- Keeps essential info: title, author, rating, language
- Combines book title, author, and language into text
- Uses TF-IDF to convert text to numerical vectors
- Creates similarity matrix between all books
- Find the input book in database
- Calculate similarity with all other books
- Return most similar books as recommendations
from books import BookRecommendationSystem
# Initialize system
recommender = BookRecommendationSystem('books.csv')
# Get recommendations
recommendations = recommender.get_recommendations('Harry Potter', 5)
# Show statistics
recommender.show_stats()- Clean, readable code
- Easy to understand algorithms
- Well-documented functions
- Handles typos with fuzzy matching
- Error handling for missing books
- Data validation and cleaning
- Data distribution charts
- Author popularity graphs
- Rating vs pages analysis
- Command line interface
- Web interface with Flask
- Real-time recommendations
book-recommendation-system/
├── books.py # Main recommendation system
├── app.py # Web application
├── requirements.txt # Dependencies
├── books.csv # book dataset
└── templates/
└── index.html # html - frontend
- Term Frequency: How often a word appears in a book's description
- Inverse Document Frequency: How rare/common a word is across all books
- Result: Important words get higher scores
- Measures angle between two vectors
- Range: 0 (completely different) to 1 (identical)
- Works well for text similarity
- Recommends items similar to what user likes
- Based on item features (title, author, genre)
- No need for other users' data
🎯 Top 2 recommendations for 'Harry Potter':
1. 📖 The Lord of the Rings
👤 Author: J.R.R. Tolkien
⭐ Rating: 4.5
🔗 Similarity: 0.85
2. 📖 The Chronicles of Narnia
👤 Author: C.S. Lewis
⭐ Rating: 4.3
🔗 Similarity: 0.78