This repository trains a Restaurant Review Sentiment Analysis model using the Naive Bayes classifier.
git clone https://github.com/remla2025-team10/model-training.git
cd model-trainingpython3 -m venv venv
source venv/bin/activatepython -m venv venv
venv\Scripts\activateMake sure you have pip up to date:
python -m pip install --upgrade pipThen install the project dependencies:
pip install -r requirements.txtpython -m restaurant_model_training.modeling.trainpython -m restaurant_model_training.modeling.train \
--data_p <path/to/raw_data.tsv> \
--processed_p <path/to/processed_data.csv> \
--bow_p <path/to/bow_model.pkl> \
--model_p <path/to/classifier> \
--bow_max_features 1000 \
--test_size 0.15 \
--random_state 10python -m restaurant_model_training.modeling.predictpython -m restaurant_model_training.modeling.predict \
--bow_p <path/to/bow_model.pkl> \
--model_p <path/to/classifier> \pip install -e .pytest tests/ -v --cov=. --cov-report=term-missingdeactivateThis repository uses Data Version Control (DVC) to manage machine learning datasets and model artifacts. We've configured a Google Drive remote storage to facilitate collaboration without duplicating large data files in Git.
Make sure you have DVC and dvc-gdrive installed. If not, you can run pip install -r requirements.txt to install all dependencies, including DVC and dvc-gdrive.
We use Google Drive as our DVC remote storage. The configuration can be set with a script (Please reach out to us to get the bash file with credentials), and it will been set up in the .dvc/config file. You can check the current remote configuration with:
dvc remote listAfter making changes to tracked data files, reproduce the pipeline:
dvc reproPush your data changes to the remote:
dvc pushPull the latest changes from the remote:
dvc pullThe structure follows the established Cookiecutter template for data science projects. Some of the structure still contains empty files/folders, as they were created according to the template and may be used in the future.
The directories you should pay attention to are the following:
data/: The folder containing all the data filesraw/: Original raw data dumpsprocessed/: The processed data directly used by the model
models/: Containes the models which have already been trainedrestaurant_model_training/: The main package (module) of this projectconfig.py: Contains the configurations such as default values and pathsdataset.py: Logic for loading and preprocessing the datafeatures.py: Logic for creating BOW featuresmodeling/: Module containing logic for model training (train.py) and predicting (predict.py)
tests/: The test files for the modeltest_data_features.py: Tests for data and featurestest_infrastructure.py: Tests for infrastructuretest_model_development.py: Tests for model training, evaluation, robustnesstest_monitoring.py: Tests for model monitoring
requirements.txt: The project dependenciessetup.py: The package setup file
- The code is tested on Python 3.12.