E-mail Classification for Automated Support Ticket Generation: Step 2 of 2, Create Web Service with Trained Models

By for October 20, 2017

Report Abuse
Email classification experiment to assign an email to one or more class(es) of predefined set of classes or work queues.
The goal of this experiment is to classify an email into one or more predefined classes or categories and to create a support ticket or assign it to correct support team. This experiment has two steps [Step 1 of 2: Train model with data and Save trained models][1] [Step 2 of 2: Create an experiment using trained models and publish it as web service][2] Next optional step is to use this web service in CRM workflow, It can be found here. *APP Source CRM code Link to be added here* It is assumed that users have completed step 1 of this experiment and has Trained models saved in Azure ML studio. In this experiment, input dataset has two raw text columns: Email Subject and Email Body, and three label columns: Case Type, Case Subject, and Queue name. Once we train the model it should predict case type of the email, case subject and the queue name to which email belongs. The pipeline is similar to the training experiment, except that there is no model training and tuning – the models trained in the previous step are loaded here and predictions are made on all input data. This experiment has following steps 1. Import Data Module 2. Data Preprocessing 3. Text Preprocessing 4. Feature Engineering 5. Score model and add web service output module 6. Deploy and Test Web Service **Experiment Work Flow:** ![Work Flow][3] **Import Data:** Import data module of this experiments loads data from Azure Blob Storage, users can replace it with their own datasets like a file on the local system or online stores like Azure SQL Storage etc. In this experiment, we are providing email subject and email body as input to the model. **Web service input** module is also added to publish it as web service. **Data Preprocessing:** In this experiment email subject and body are combined as single text column Email_text. An entire row is deleted if any missing values present in data. Modify this data preprocessing steps depending on data. ![Data Preprocessing][4] **Text Preprocessing:** Use preprocess text module to specify required text preprocessing step such as remove stop words, remove duplicate char, replace numbers, convert to lower case, stem words etc.. ![Preprocess Text][5] The user can include email specific preprocessing steps if input email is noisier. **Feature Engineering:** In this step, we use **feature hashing** to convert variable-length text to equal length numeric feature vector.The objective of using feature hashing is to reduce dimensionality. ![Feature hashing][6] **Score Model:** Use Trained models from step 1 and connect to left port of **score model** and input data to right port of score model. Run the experiment and visualize the output to see predicted output along with probabilities. In this experiment execute R script module is added to fetch the scored label and probabilities and rename it for the end user to understand. ![predicted values and scored Probabilities][7] Repeat this step for predicting other two outputs and merge the result using **Add columns** Module and connect the combined results to the **web service output** module. ![Web service output][8] **Deploy and test web service:** Run the experiment and click on the deploy web service button at the bottom. A web service will be created for this predictive experiment, with all the details required to consume this web service. ![Web service][9] Click on the test button to test the Web service and provide input to require fields. ![Web service test][10] It will return predicted outputs along with probabilities. **Conclusion:** This experiment template can be used for Variety of email classification problems like sentiment analysis, spam filtering etc. In this experiment, we are predicting three label columns that are independent of each other but with little customization, this experiment can predict hierarchical outputs as well. [1]: https://gallery.cortanaintelligence.com/Experiment/Email-Classification-for-Automated-Support-Ticket-Generation-Step-1-of-2-Train-and-Evaluate-Models-3 [2]: https://gallery.cortanaintelligence.com/Experiment/E-mail-Classification-for-Automated-Support-Ticket-Generation-Step-2-of-2-Create-Web-Service-with-Trained-Models-2 [3]: https://sivakumarstorage.blob.core.windows.net/emperimentscreenshots/AppSource/Web%20service%20work%20flow.PNG [4]: https://sivakumarstorage.blob.core.windows.net/emperimentscreenshots/AppSource/data%20preprocessing%20step%202.png [5]: https://sivakumarstorage.blob.core.windows.net/emperimentscreenshots/AppSource/text%20preprocessing%20step%201.png [6]: https://sivakumarstorage.blob.core.windows.net/emperimentscreenshots/AppSource/1%20-%20Feature%20Hashing.PNG [7]: https://sivakumarstorage.blob.core.windows.net/emperimentscreenshots/AppSource/2%20-%20r%20code%20to%20select%20probabilities.PNG [8]: https://sivakumarstorage.blob.core.windows.net/emperimentscreenshots/AppSource/2-%20web%20service%20output.PNG [9]: https://sivakumarstorage.blob.core.windows.net/emperimentscreenshots/AppSource/2-%20web%20service.png [10]: https://sivakumarstorage.blob.core.windows.net/emperimentscreenshots/AppSource/2%20-%20web%20service%20test.PNG