Giter VIP home page Giter VIP logo

ml-cloud-deployment's Introduction

ML-Cloud-Deployment

This project contains implementation for performing grid search and saving the trained model for udemy scrapped dataset. The trained model can then be deployed on both Azure machine learning and Google compute engine.

The project is structured as follows:

1. The model.py reads the input dataframe and selects the column according to pre-computed feature importance. It then splits the dataframe into training and test set. Finally, it performs a grid search to find the best parameters for the XGBRegressor and save it.

2. The deploy folder contains two subfolders for azure and gce deployment which is explained in the relevant section.

To configure the environment locally for testing clone and then change directory to repository root and execute:

conda env create -f conda_env.yml

conda activate production_environment

Model Training:

We use the popular XGBoost library and train a XGBRegressor to predict the predictive_score column. A grid search is performed over the number of estimators, max depth and the learning rate with 5-fold cross-validation. The trained model is saved in the models directory. Following are the test metrics:

R2_score: 0.97124, mean absolute error: 0.069653, explained variance: 0.971242

To enable training set the TRAIN flag to true in the model.py script and execute it.

Deployment:

The model can be deployed on both Azure and google cloud.

Azure Deployment:

To deploy on azure change to execute deploy.py in the deploy/azure directory. The user needs to provide a valid config file in the .azureml directory and also make sure that a pre-trained model is in the relevant directory. It also contains the score.py script which is used to compute and return the predictions. An environment.yml file is also provided to create an appropriate conda environment.

Google Compute Engine Deployment:

The model can also be deployed on GCE. First, create a project on google cloud and add a VM in the google compute engine. Then configure ssh access and drop to a terminal. Then copy and execute the deploy_gce.sh bash script. This clones the repository, configure the environment and starts a Gunicorn server binding the flask app to return the predictions from the gce VM endpoint.

Testing:

Two files are provided for testing the deployed model. The azure testing file contains a implementation for testing and the gce testing file requires the user to enter the endpoint address after deployment. To test the azure endpoint change url to live endpoint and just execute the test_azure_endpoint.py.

ml-cloud-deployment's People

Contributors

sabbih-shah avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.