Analytics Vidhya has long been at the forefront of imparting data science knowledge to its community. With the intent to make learning data science more engaging to the community, we began with our new initiative- “DataHour”.
DataHour is a series of webinars by top industry experts where they teach and democratize data science knowledge. On 23rd April 2022, we were joined by Miss Ria Nag for a DataHour session on “Text-Based Classification Using Artificial Intelligence, AI”
Ria is a leader and a mentor in Data Science and Machine Learning. She has been working for the past three years at Oracle as a data scientist leading to the development of end-to-end development and the launch of Oracle Construction Intelligent Cloud Services. Oracle Construction Intelligent Cloud Services is a new suite of artificial intelligence, AI and analytics applications to enable informed project decisions in the engineering and construction industry. She has multiple US patents in the field of machine learning and NLP. She has been the recipient of the AnalyticsIndia Magazine under 40 data scientist award.
Here is the recording of the session :
Are you excited to dive deeper into the world of Artificial Intelligence? We got you covered. Here you’ll get major highlights of this session: Text-Based Classification Using Artificial Intelligence.
This session of Text-Based Classification on Artificial Intelligence will focus on:
Let’s first look into Text Classification:
Text Classification is a machine learning technique that assigns a set of predefined categories to open-ended text. It is one of the fundamental tasks in Natural Language Processing(NLP) with broad applications such as sentiment analysis, topic labeling, spam detection, and intent detection. Any open ended-text/input is provided to the text classification model, and then the model labels the text with a particular category, and then it is shown in the UI(User Interface) as an output with the different categories associated with every text.
Next learning is:
Manual classification is time-consuming and expensive, where a person has to go through every record of text and understand which label or category to assign to the text. So, it becomes very expensive in the long run. It is also not scalable.
In contrast, AI-based classification is scalable, consistent, and faster. So, I prefer this method more for the classification of text.
There are three types of AI-based text classification:
Rule-based systems: There are sets of rules based on which an algorithm will classify an open-ended text as a particular category or label.
Machine learning-based systems: Here, the classifier is trained on a labeled dataset, you have to build this classifier, and then this classifier will label every text record.
Hybrid Systems: This is a combination of both rule-based and machine learning-based systems.
There are a few datasets that you need to consider for training a classifier, and these are:
(A) Topic classification: In this, the classifier assigns a particular topic to every record. Here you can use:
(B) Sentiment analysis: In this, you’ll build classifiers for sentiment or star analysis. For this, you can use:
These are:
It’s up to you totally which language you want to use for building your classifiers.
Note: You can go through this case study from (Lattice Journal). Here is the link to this journal Lattice-Association of Data Scientists
The focus or problem statement here is:
Health and Safety issues and incidents that occur in the construction industry lead to:
So, it’s important to mitigate these issues at the early stages to reduce the risk of major accidental happenings later on. For this, we’ll try to develop a solution that would identify any health and safety issues if they arise associated with any open-ended text data. We’ll try to build a classifier that will detect this health and safety issue at the first instance itself, consequently reducing the chances of major accidents in the future.
The solution for the same can be summed up as:
The approach followed in the use case:
CRISP-DM (Cross industry standard practices for data management) which involves
Source: Ms. Ria Naag’s presentation
Note: It’s a case-by-case study, so, for different classifiers, you need to use different kinds of evaluation metrics.
Data Preparation
Note: We need to vectorize the data because we can’t feed data directly to the classifier. We must convert it into a numerical dataset. There are two methods of performing the same:
Training and testing: Here, we have set 90% for training and 10% for testing, and classes are in the same ratio as in the training and testing dataset. We have developed three machine learning (ML) models based on a trained dataset which is the Scaled document embedding matrix. This is needed to scale all features so that all the features will be at the same scale. It’s necessary so that none of the features have a differential impact on the final product due to differences in scale.
The Scaled document embedding matrix was used for building 3 base classifiers:
This is an ensemble classifier that we’ll construct over three base classifiers(discussed recently) and all these base classifiers are from different theoretical backgrounds to avoid bias and redundancy. On the basis of each base classifier majority voting, the ensemble model will predict whether the model has associated health and safety issues or not
The ensemble model predicts a txt record to be at risk if any two of the three base classifiers classify the record as a health and safety risk
Source: Ms. Ria Naag’s presentation
After deploying the best ensemble model, the predictions are available to the customer. These are available in the form of dashboards, warnings, recommendations, etc. These explain whatever risks are there in the past in a certain period. Now, it depends on the customer whether he’ll agree with the model predictions or not. To create a new set of labels where customers will add tags according to their case understanding and vice versa. There is a check that is to create a feedback loop in the system. All changes will automatically update until we arrive at the best predictions/result.
I hope you have thoroughly understood what text-based classification is and how to use AI in text classification. Then the use-case has made the concepts more clear and simple for you. Try to apply them further in real-time according to your understanding.
Hope to see you there.