This repository shows how to use MLflow tracking, projects, and models modules.
logs/train_model.log
: file to log errorsMLproject
specifies the conda environment to run the project and definescommand
andparameters
inentry_points
Dockerfile
used to build the image to serve the modelconda.yaml
used to create virtual environment referenced by theMLproject
mlflow_model_driver.py
: finds best training run and starts a REST API model server based on MLflow Models in docker containers.train.py
: contains a file that trains a scikit-learn model and uses MLflow Tracking APIs to log the model and its metadata (e.g., hyperparameters and metrics)preprocess.py
: contains a file that perform data processingutils.py
: contains a file with helper functionsmain.py
: contains a file where we orchestrate everything into one worflowdata/raw/hour.csv
: contains raw data Bike Sharing Dataset Data Setdata/processed/data_preprocessed.csv
: contains processed data
Prerequisites:
- Python 3
- Install Docker per instructions at https://docs.docker.com/install/overview/
- Install Anaconda
- clone this repo:
git clone https://github.com/haythemtellili/ML_pipeline.git
- Enter to ML_pipeline:
cd ML_pipeline
- build the image for the project's Docker container environment:
docker build -t mlflow_example -f Dockerfile .
- create conda environment:
conda env create --name ml-pipeline --file=conda.yaml
- activate conda environment:
conda activate ml-pipeline
- Run the workflow:
mlflow run .
In the same repo directory, run mlflow ui --host 0.0.0.0 --port 5000
UI is accessible at http://localhost:5000/
In the same repo directory, run python3 mlflow_model_driver.py
curl --silent --show-error 'http://localhost:5001/invocations' -H 'Content-Type: application/json' -d '{
"columns": ["year","hour_of_day","is_holiday","weekday","is_workingday","temperature","feels_like_temperature","humidity","windspeed","year.1","dayofweek","year_season","hour_workingday_casual","hour_workingday_registered","count_season","season_1","season_2","season_3","season_4","weathersit_1","weathersit_2","weathersit_3","weathersit_4","mnth_1","mnth_2","mnth_3","mnth_4","mnth_5","mnth_6","mnth_7","mnth_8","mnth_9","mnth_10","mnth_11","mnth_12"
],
"data": [[0,-1.670003982455765,0,6,0,-1.3346475857785418,-1.0932806043146361,0.9473724999661597,-1.5538885118643786,2011,5,2011.1,0,0,56.0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0]]
}'