Sentiment Analysis with Deep Learning and FastAi

Sentiment Analysis is the process to identify and extract subjective information from text files for determining the emotional tone behind a series of words, used to gain an understanding of the opinions and emotions expressed in text.

In this post, I will explain how we extract text data to predict sentimental analysis. Here we have used Movie review dataset to explain how FastAi works for Sentimental analysis problem.

Lets look at the data

Let’s have a look on the overview of data and know the data types of each features, to understand the importance of features.
For this problem, our target values have 5 different values as follows :
0 – negative
1 – somewhat negative
2 – neutral
3 – somewhat positive
4 – positive



Load and analyse data

Fast ai expects the data to be loaded as a Data Bunch and then a Fast ai Learner can use this data for the models.  Here, we will first create data bunch with our train dataset


Fit the deep learning model with domain specific data

First we will fit our model with train data without target values so that our model knows better about our data.


Re-fit model with classification label

Here we will re-fit our model with our target values and tuned our model for better accuracy result.

Let’s predict the target values and compare with original target values.

Get Prediction

Let’s get the prediction and create the submission file to submit it in Kaggle.

All the code

All the code for this task can be found here on Kaggle kernels:

Leave a Reply

Your email address will not be published. Required fields are marked *