An intelligent book recommendation system that uses semantic search and emotional analysis to suggest books based on user preferences.
- Semantic Search: Find books using natural language descriptions
- Category Filtering: Filter recommendations by book categories
- Emotional Tone Analysis: Get recommendations based on emotional content (Happy, Surprising, Angry, Suspenseful, Sad)
- Interactive Dashboard: User-friendly Gradio interface
- AI-Powered: Uses OpenAI embeddings and LangChain for semantic understanding
The system uses a dataset of 7,000+ books with metadata including:
- Book titles, authors, and descriptions
- Categories and genres
- Publication years and ratings
- Emotional analysis scores
- Book covers and thumbnails
-
Clone the repository
git clone https://github.com/KatyaMarush/book_recommender.git cd book-recommender -
Create virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Prepare Data Run the Jupyter notebooks in the correct order to prepare the required data files:
# 1. Data exploration and initial processing jupyter notebook data-exploration.ipynb # 2. Vector search preparation jupyter notebook vector-search.ipynb # 3. Text classification for categories jupyter notebook text-classification.ipynb # 4. Sentiment analysis for emotions jupyter notebook sentiment-analysis.ipynb
This will create the necessary processed files:
books_cleaned.csv,books_with_categories.csv,books_with_emotions.csv, andtagged_description.txt. -
Environment Variables Create a
.envfile with your OpenAI API key:OPENAI_API_KEY=your_api_key_here
After running all notebooks, launch the interactive Gradio dashboard:
python gradio-dashboard.pydata-exploration.ipynb: Initial data analysis and preprocessingvector-search.ipynb: Vector search implementationtext-classification.ipynb: Text classification modelssentiment-analysis.ipynb: Emotional content analysis
book-recommender/
├── gradio-dashboard.py # Main web interface
├── requirements.txt # Python dependencies
├── config.py # Configuration settings
├── test_recommender.py # Unit tests
├── cover_placeholder.jpg # Default book cover
├── *.ipynb # Jupyter notebooks for analysis
└── data files (created by notebooks):
├── books_cleaned.csv
├── books_with_categories.csv
├── books_with_emotions.csv
└── tagged_description.txt
- Python: Core programming language
- Gradio: Web interface framework
- LangChain: AI/ML framework for semantic search
- OpenAI: Embeddings and language models
- Pandas: Data manipulation
- ChromaDB: Vector database for similarity search
- Transformers: NLP models for text analysis
- Data Processing: Books are analyzed for categories and emotional content
- Semantic Embeddings: Book descriptions are converted to vector embeddings
- Query Processing: User queries are embedded and compared to book vectors
- Filtering: Results are filtered by category and emotional tone
- Ranking: Books are ranked by relevance and emotional scores
- Run the notebooks in order to prepare data
- Launch the Gradio dashboard:
python gradio-dashboard.py - Enter a book description: "A story about forgiveness"
- Select a category: "Fiction"
- Choose emotional tone: "Happy"
- Get personalized book recommendations with covers and descriptions
This project is for educational and research purposes.
Feel free to submit issues and enhancement requests!