Skip to content

ValentinPatrakeev/Recommendation-system-social-network

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Recommendation-system-social-network


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:

  1. Download data and EDA.ipynb - Loading data from the database to the Jupyter Hub, reviewing the data
  2. Create features.ipynb - Creation of features and training sample
  3. Train model .ipynb - Training models and assessing their quality on the validation set.
  4. Test service.ipynb - Imitation of a printer on the jupyter notebook
  5. 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

Conceptual diagram of working with data

Main libraries used

PANDAS NUMPY fastapi sqlalchemy catboost pydantic psycopg2 uvicorn

Quality Model Assessment:

  • 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

Start service

At the moment, the project is not invested in Docker (close to implementation), so you can start the service as follows:

  1. Clone the project locally:
    git clone git@github.com:ValentinPatrakeev/Recommendation-system-social-network.git

  2. Navigate to the project folder:
    cd Recommendation-system-social-network

  3. Install dependencies using Poetry:
    poetry install

  4. Request the .env file – this file should contain the PostgreSQL service key.

  5. 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

  6. 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.

About

referral system in a fictitious social network

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors