This server extracts data, trains and deploys a model, and makes predictions using a matrix factorization recommender system.
- Data from MongoDB is preprocessed and converted into an interaction matrix, which is then stored in a BigQuery Datawarehouse.
- The interaction matrix is used to train a MATRIX FACTORIZATION model using the Stochastic Gradient Descent (SGD) algorithm.
- The trained model is then transferred to the Vertex AI model registry.
- From the model registry, the model is deployed to a Vertex AI prediction endpoint.
- The prediction endpoint is then used to make recommendations based on the interaction matrix.
- Python >= 3.8
- Google Cloud SDK
- MongoDB
- BigQuery
- Local Server
- Complete the SDK installation and setup
- Run:
gcloud auth application-default login
- Remote Server
- Run:
gcloud auth activate-service-account --key-file=path/to/the/service-account-key.json
- Run:
export GOOGLE_APPLICATION_CREDENTIALS="path/to/the/service-account-key.json"
Note: Place the service-account-key.json
in the root directory. It will be ignored by git.
- Copy the
.env.example
file to.env
and fill in the required values. - Create a Python virtual environment:
python3 -m venv env
- Activate the environment:
source env/bin/activate
- Install dependencies:
pip install -r requirements.txt
Note: After installing any new dependencies, update the requirements.txt
file: pip freeze > requirements.txt
To run the application, execute: python3 main.py
When contributing to this project, please adhere to the following guidelines:
- Fork the repository and create a new branch for your feature or bug fix.
- Write clear, commented code and update documentation as necessary.
- Submit a pull request with a detailed description of your changes.