How to Create a Text Classification Model and Deploy it as a Web Service in Azure

Jun 3, 2022 | Educational

Are you looking to automate the classification of support tickets using text analysis? In this guide, we’ll walk you through the process of building a model for text analysis and deploying it as a web service in Azure.

Project Description

This project, created by Microsoft in collaboration with Endava, aims to provide a solution for automatic support ticket classification. The process utilizes various tools, primarily:

This project covers a spectrum of tasks, from data cleaning and preparation to creating a web service for deployment.

Results and Learnings

Main Challenge and Initial Assumptions

The main challenge was to develop a model capable of categorizing support tickets automatically to improve efficiency at Endava’s helpdesk. By leveraging a dataset of approximately 50,000 classified support tickets, the initial assumptions revolved around how well the model could generalize across different ticket types.

Dataset

In this project, we used an internal dataset from Endava that was anonymized and stripped of sensitive information. The data preparation involved careful cleaning to ensure the model would not learn from any personal data. You can access the anonymized dataset through this link: Dataset Here.

Training and Evaluation Results

We utilized the Azure Machine Learning Services to train our models, experimenting with algorithms such as SVM and Naive Bayes. Surprisingly, Naive Bayes yielded more consistent results. Below is a simplified analogy to illustrate the process:

Analogy: Imagine training a dog to recognize various toys. You began by showing it several types. Initially confused, the dog gradually learns to associate specific toys with certain commands. This is akin to our model learning how to classify tickets based on the words and phrases found in the support tickets. Eventually, with enough practice (data), it can categorize new toys accurately.

Model Deployment and Usage

The final model was packaged as a RESTful web service using the Flask framework, enabling easy access to predictions through an API.

Run the Example

Prerequisites

  • Download the repository content.
  • Set up a Python environment. For convenience, Azure’s Data Science Virtual Machine can be used.
  • Install the required dependencies with the command: pip install -r requirements.txt.
  • Download the Endava support tickets dataset as previously linked.

Train and Evaluate the Model

Run the script 2_train_and_eval_model.py to initiate the training process. Feel free to adjust parameters to suit your model’s needs.

Deploy Web Service

Inside the web service folder, you’ll find all necessary scripts to deploy your service to Azure. You can refer to the resources in GitHub Repository.

Code Highlights

Throughout the repository, multiple scripts effectively clean, prepare, and train the dataset. The data preprocessing script, for instance, addresses sensitive information removal:

def encryptSingleColumn(data):
    le = preprocessing.LabelEncoder()
    le.fit(data)
    return le.transform(data)

This function anonymizes specific columns in the dataset, ensuring privacy.

Troubleshooting Ideas

If you run into challenges, such as dependency issues or model accuracy problems, consider the following:

  • Ensure all dependencies are installed correctly.
  • Review your data preprocessing steps to confirm that no critical information is omitted.
  • If model performance isn’t meeting expectations, experiment with different machine learning algorithms or adjust hyperparameters.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox