xbphat / ap-sample

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This repository contains sample code with results of 1:1 engagement with Action Press. Action Press LLC is a part of Action-Media company - the largest supplier of professional media in Russia. To inform customers about news and stimulate subscriptions Action Press has developed an internal outbound marketing system that regularly send emails to the customer base. System has used full-text search with a basic automation which was not so effective as expected, as users were required to manually check and sort replies on the emails, forwarding them to corresponding departments. Main types of consumers responses were autoreplies, requests to remove from the mailing list, clarifying questions and requests for new subscriptions. The core idea of the engagement with us was in development of a machine learning model to make the process as much automatic as possible and then operationalize it to be used with other parts of the system in production. In this repository you can find ML model building scripts and a way Azure Functions can be used as a host for python ML models in a simple and cost effective way.

Please, check the article for more info:

Setup

Development environment

Prerequisites: Windows PC with the following software installed:

  • Anaconda version 4 or higher. Download it here for free.
  • Visual Studio Code with Python and Jupyter extensions installed. Download it here for free. Install extensions manually using the links or from VS Code itself.

The code should possibly work on Linux and Mac, but hasn't been tested. A subsequent steps assumes that you have a PC with Windows 10.

  1. Open the command line with current working directory set to any place you want this code to be. Clone the repository. Replace the url with your own if using the fork.
git clone https://github.com/evgri243/ap-sample.git
  1. Change current working directory to the cloned folder.
cd ap-sample
  1. Create Anaconda environment with all required packages installed using the command below. If not overwritten it will be called ap-sample.
conda env create -f environment.yml
  1. Activate newly created environment.
activate ap-sample
  1. Run Visual Studio Code from the same command prompt. This is required to correctly forward all environment settings associated with Python environment. Please, rerun steps 4-5 every time you want to work with this code.
code
  1. Open Folder with the whole repository in VS Code using GUI. And from Debug (Ctrl+Shift+D) run configuration named Setup (Python) to install required NLTK corpora.

  2. Replace data\data.csv with your own data in the same format and step through Experiments\TrainingExperiment.py to train your model.

  3. Once ready, replace Score\debug\input.csv with your own data in the same format and step through Score\Score.py to score results.

Please, check the article for more info.

Azure Deployment

The next steps require active Microsoft Azure subscription. If you don't have one, create one for free.

  1. Fork the repository to your GitHub account.

  2. Go to portal.azure.com and create Azure Function, Click big + ont the left side, search for Function App and click Create. This steps deploys Azure Functions and Azure Storage to you subscription. For more information check the docs.

  3. Using Azure Portal configure integration between Azure Functions and the forked repo. Go to your function -> Platform Features -> Deployment option, click Setup and finish the wizard. Wait for initial deployment to succeed. Check this docs for additional information.

  4. Go to the corresponding storage account (created with Function) using Azure Portal or Azure Storage Explorer. Put sample input file Score\debug\input.csv (or your owned data if model is changed) to input folder of mail-classify container. Wait for results to appear in output folder.

Please, check the article for more info.

About


Languages

Language:Python 100.0%