It is necessary to implement a recommendation system for posts on a social network, which will return posts for each user at any time that will be shown to the user in his social network feed.
Initial data:
As basic raw data - table with PostreSQL
1) Users - user data
2) Posts - post data
3) Feeds - user activity data
- The set of users is fixed and no new ones will appear
- Models are not retrained when using services
Uploaded to the repository:
- Download data and EDA.ipynb - Loading data from the database to the Jupyter Hub, reviewing the data
- Create features.ipynb - Creation of features and training sample
- Train model .ipynb - Training models and assessing their quality on the validation set.
- Test service.ipynb - Imitation of a printer on the jupyter notebook
- FastAPI service - The service downloads data from PostgreSQL, loads the model and, based on a get request, issues recommendations to each user in JSON format
- In train model various metrics and their comparisons are presented.
- The best model based on the metric HitRate@5 (the metric takes the value = 1 if the user liked 1 or more posts out of 5 posts, 0 if none of the 5 were liked) -- On test data, the catboost model showed HitRate@5 = 0.866
At the moment, the project is not invested in Docker (close to implementation), so you can start the service as follows:
-
Clone the project locally:
git clone git@github.com:ValentinPatrakeev/Recommendation-system-social-network.git -
Navigate to the project folder:
cd Recommendation-system-social-network -
Install dependencies using Poetry:
poetry install -
Request the
.envfile – this file should contain the PostgreSQL service key. -
Start the service:
- Activate the virtual environment:
poetry shell
- Run the FastAPI server:
poetry run uvicorn app:app --host 0.0.0.0 --port 8000 -
Test the service using a browser or Postman:
http://localhost:8000/post/recommendations/?id=200&time=2023-11-12%2022:57:45
In this request template, you can change the ID and time. Range of possible IDs:199 < id < 163206.

