A hybrid recommendation system that combines collaborative filtering, content-based filtering, and sentiment analysis with reinforcement learning to provide personalized book recommendations. This system uses real-time feedback and continuous learning to adapt to users’ preferences dynamically.
- Project Description
- Key Features
- Architecture Overview
- Technologies Used
- Installation
- Configuration
- Usage
- Project Structure
- License
This book recommendation system is designed to offer users personalized book suggestions based on their interaction history, demographic data, and review sentiments. The system uses reinforcement learning to select the optimal recommendation method (collaborative, content-based, or sentiment-based) dynamically, improving accuracy and user satisfaction.
- Hybrid Model: Combines collaborative, content-based, and sentiment-based filtering techniques.
- Real-Time Adaptability: Reinforcement learning optimizes recommendations dynamically.
- User Sentiment Analysis: Analyzes user reviews to enhance personalization.
- Scalable Database Integration: MySQL database stores user, book, and interaction data.
- User Interface Layer: Manages user interactions (registration, login, book search, and reviews).
- Recommendation Engine Layer: Combines the collaborative, content-based, and sentiment-based filtering agents.
- Data Management Layer: Uses MySQL to store user data, ratings, reviews, and book metadata.
Refer to the architecture_diagram.png
file for a high-level overview of data flow.
- Python: Core programming language
- Flask: Web framework for developing the application
- SQLAlchemy: ORM for managing database interactions
- MySQL: Database management system
- PyTorch: Used for reinforcement learning
- Scikit-Learn: For collaborative and content-based filtering
- Hugging Face Transformers: Sentiment analysis with BERT model
- Pandas and Numpy: Data manipulation and processing
- Python 3.8 or higher
- MySQL server
- Git
-
Clone the Repository:
git clone https://github.com/your-username/book-recommendation-system.git cd book-recommendation-system
-
Set Up Virtual Environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install Required Packages:
pip install -r requirements.txt
-
Set Up MySQL Database:
- Create a MySQL database:
CREATE DATABASE book_recommendation_db;
- Update your configuration file (
config.py
) with the database credentials:SQLALCHEMY_DATABASE_URI = 'mysql+mysqlconnector://root@localhost/book_recommendation_db' SECRET_KEY = 'your_secret_key'
- Create a MySQL database:
-
Initialize Database Tables:
flask db init flask db migrate -m "Initial migration." flask db upgrade
-
Download and Set Up the Dataset:
- Download the datasets for books, users, reviews, and ratings.
- Place them in the
data/
folder. - Run any necessary data preprocessing scripts if needed.
Create a .env
file with your environment variables:
FLASK_APP=app
FLASK_ENV=development
DATABASE_URL=mysql+mysqlconnector://root@localhost/book_recommendation_db
SECRET_KEY=your_secret_key
-
Run the Flask Application:
flask run
-
Access the Application: Open a web browser and go to
http://127.0.0.1:5000
. -
User Actions:
- Register and Log In: Users can register and log in to the application.
- Search and Review Books: Search for books by title, author, or ISBN, and submit reviews.
- View Recommendations: See personalized book recommendations based on user preferences and feedback.
book-recommendation-system/
│
├── app/ # Flask application files
│ ├── __init__.py # App initialization
│ ├── models.py # Database models for Users, Books, Ratings, Reviews
│ ├── routes.py # Application routes
│ └── templates/ # HTML templates for UI
│
├── data/ # Dataset files
│
├── agents/ # Recommendation agents
│ ├── collaborative_agent.py # Collaborative filtering logic
│ ├── content_based_agent.py # Content-based filtering logic
│ └── sentiment_based_agent.py # Sentiment analysis logic
│
├── rl_model/ # Reinforcement learning components
│ ├── actor_critic.py # Actor-Critic model for agent selection
│
├── config.py # Configuration settings
├── requirements.txt # Required packages
└── README.md # Project documentation
This project is licensed under the MIT License. See the LICENSE file for details.
your-username
and your_secret_key
, with your actual information.