{"id":15415237,"url":"https://github.com/simonmacor/book-recs","last_synced_at":"2026-04-14T00:05:18.695Z","repository":{"id":255910718,"uuid":"850090078","full_name":"simonmacor/book-recs","owner":"simonmacor","description":null,"archived":false,"fork":false,"pushed_at":"2024-09-07T20:40:05.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-06T02:06:15.798Z","etag":null,"topics":["neural-network","python","pytorch","recommender-system"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simonmacor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-30T21:25:56.000Z","updated_at":"2024-09-07T20:40:05.000Z","dependencies_parsed_at":"2024-09-07T20:25:14.574Z","dependency_job_id":"c7d1ddf9-03d5-4a3b-8a30-df9452d6610c","html_url":"https://github.com/simonmacor/book-recs","commit_stats":{"total_commits":4,"total_committers":1,"mean_commits":4.0,"dds":0.0,"last_synced_commit":"89572b87be0e3cee55e96beb9f7d701f7b4561f4"},"previous_names":["simonmacor/book-recs"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonmacor%2Fbook-recs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonmacor%2Fbook-recs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonmacor%2Fbook-recs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonmacor%2Fbook-recs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simonmacor","download_url":"https://codeload.github.com/simonmacor/book-recs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246547370,"owners_count":20794970,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["neural-network","python","pytorch","recommender-system"],"created_at":"2024-10-01T17:07:29.362Z","updated_at":"2026-04-14T00:05:18.656Z","avatar_url":"https://github.com/simonmacor.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CI](https://github.com/simonmacor/book-recs/actions/workflows/ci.yml/badge.svg)](https://github.com/simonmacor/book-recs/actions/workflows/ci.yml)\n# Book Recommender System\n\nThis project implements a book recommendation system based on user preferences, such as theme, period of the author, and literary style. It is built using **SQLAlchemy** for database management and **PyTorch** for training the neural network model that recommends books to users. **Alembic** is used for database migrations.\n\n## Prerequisites\n\nTo run this project, you need the following installed on your machine:\n\n- **Python 3.8+**\n- **pip** (to install Python dependencies)\n- **Docker** and **Docker Compose** (to run the application in a containerized environment)\n- **virtualenv** (optional but recommended)\n\n## Project Setup\n\n### Step 1: Clone the Project\n\n```bash\ngit clone https://github.com/your-username/book-recommender.git\ncd book-recommender\n```\n\n### Step 2: Set Up a Virtual Environment (Optional but Recommended)\n\nIt is recommended to use a virtual environment to isolate the project dependencies.\n\n```bash\npython3 -m venv .venv\nsource .venv/bin/activate  # For Linux/Mac\n# Or for Windows\n# .venv\\Scripts\\activate\n```\n\n### Step 3: Install Dependencies\n\nInstall the dependencies listed in the `requirements.txt` file.\n\n```bash\npip install -r requirements.txt\n```\n\n### Step 4: Set Up the Database\n\nThe project uses **PostgreSQL** as its database, managed via Docker. See the **`docker-compose.yml`** and modify it according to your needs.\n\n### Step 5: Start containers\n\nTo start PostgreSQL and the Python app, use Docker Compose:\n\n```bash\ndocker-compose up --build\n```\n\nThis will start both PostgreSQL and the Python application in separate containers.\n\n### Step 6: Apply Migrations\n\nAlembic is used for managing database schema changes. To set up Alembic:\n\n```bash\n   docker-compose exec app alembic upgrade head\n   ```\n\n\n## Using the Recommendation Script\n\nThe **`recommender/recommender.py`** file is the main script for the recommendation system. Here's how to run it inside the Docker container:\n\n```bash\ndocker-compose exec app python -m recommender.recommender\n```\n\nThis will train the model using user preferences and provide book recommendations.\n\n### Explanation of the Recommendation Model\n\nThe model uses a neural network to match books with user preferences. It encodes each book and user preference into a vector, then concatenates these vectors to predict whether a user will like a given book.\n\nThe model uses PyTorch and has three main layers:\n- **Layer 1**: A linear layer to reduce the input dimension.\n- **Layer 2**: A second linear layer to learn more compact representations.\n- **Output Layer**: A final layer with a sigmoid activation function to predict the likelihood of a match between the user and the book.\n\n## Unit Tests\n\nUnit tests are defined in the **`tests/test_recommender.py`** file and verify the correct functioning of the models and the recommendation system.\n\n### Running Unit Tests with `unittest`\n\nYou can run the unit tests inside the Docker container using `unittest` as follows:\n\n```bash\ndocker-compose exec app python -m unittest discover -s tests\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonmacor%2Fbook-recs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimonmacor%2Fbook-recs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonmacor%2Fbook-recs/lists"}