# How to categorise customer complaint using NLP

I have a dataset of community complaints and I would like to build a NLP model on those descriptions and tag a category (can be referred for an inspection or Not ie "Not referred) to each of them. Boolean answer ( Yes or No) would suffice my requirement.

For example: Our customer service department process complaints that are received via phone or email with "referred" or "not referred" status. Right now they are checking descriptions to classify them manually as "referred" or "not referred". My ultimate goal is to automate the whole and build a Machine Learning Model which gives a binary output "Yes" or No" based on descriptions. So that, they dont need to check manually and process those complaints. That ML model should categorise the future complaints into two buckets "Referred" "Not Referred" The classification of the issues they have received into buckets will help the department to provide customized solutions to the customers in each group.

Is there a way in NLP to build and train a model to automate this process? I have been reading stuffs about NLP for the past couple of days and it looks like NLP has a lot of good features to get a head start in addressing this issue. Could someone please guide me with the way I should use NLP to address this issue?

Based on recent research and recommendation, i read few article on this task. Below screenshot from one of them;

In that print section he has passed one index row to get sentiment output. Can I get similar output for multiple rows if i dont initialise iloc[0]?

That is what I am after. We receive a bunch of messages daily from the community assisting Line and want to classify them into two buckets – of interest, not of interest.

• This is a case of binary classification using textual data. This is a very common problem and could be approached in multiple ways. Jan 10 at 6:26
• Take the manually labelled data and train a NLP model on it. There are many articles/tutorials on Text Classification using NLP. A simple Google search will point you in the right direction Jan 10 at 7:43
• Hi @spectre, yup i did a google search for sure. There are plenty articles floating around. not sure if a tensor flow or ML model will server my requirements. I have built one skeleton using ML. but unable to binarize the output automatically. Jan 12 at 4:16
• @adey27 what kind of model you use depends on many factors. I would suggest try different models and see which gives the best results. Also for the model you have built can you post some more details about it so as to get a better diagnosis\ Jan 13 at 7:12
• @spectre, I've developed a model which can classify based on the free texts and categories them to see if there is any correlation. It serves for different purpose. Jan 14 at 6:24

In case you have labeled data (previous complaints labeled by humans), you can implement a standard binary text classification model. A rather simple approach would be to encode the text e.g. as TFIDF or "one hot" and run a simple classification task to learn of some text belongs to label "referred" or "not referred" (which would be 0, 1 encoded).

Alternatively, you can employ more sophisticated methods, e.g. by using neural nets. Keras for instance provides a number of useful examples. You can also look into BERT (as mentionned by you per tag). You can also check self supervised learning if you only have few labeled training observations.

In case you do not have labels, you can also "cluster" the text by topics using topic modeling, using Latent Dirichlet Allocation. This usually works quite well to separate topics and might be worth a try.

• I tried with TFIDF. but didnt get the desired output. Would like to give it a go with your second option which I dont have prior knowledge. doing some readings on the second option. any suggestions on that part? Jan 18 at 23:52
• What option neural nets or topic modeling? Jan 19 at 12:26
• Hi @pete. Nueral nets Jan 21 at 6:31
• I would look into using a pretrained bert tensorflow.org/text/tutorials/fine_tune_bert / github.com/CyberZHG/keras-bert Jan 21 at 8:07

What you are looking for is a so-called sentiment-analysis in NLP. In this article, you will find an instruction on how to train a Convolutional Neural Network with a BERT Encoder for a sentiment-analysis.

You could use this example and just replace the training data with movie reviews (positive / negative) with some of your labeled data. Definitely worth a try:)

• very good article to refer. I have updated my above question with another requirement Jan 14 at 6:17
• so first of all the section that you refer to is not predicted by the model. That is the training data from the csv. In the last code block of the article, I actually do automated prediction for a list of reviews. In my case, this includes too examples, but you can do the list as long as you. So just put all your reviews in a list and then adjust the last code block. Jan 14 at 18:02
• I am unable to save test set as binary output in csv file. will u be able to help me out? Feb 17 at 4:51