Tweets Analysis

The goals are to predict if the tweets are positives, neutrals or negatives and to determine what are the topic of the tweet (Google, Tweeter, Apple or Microsoft). Two csv were given. The first one was for training and the other one for testing. Each csv contains 4 columns: sentiment, topic, date and tweet.

First of all, the tweets were in many languages: arabic, spanish, portuguese, english and japanese. So differents libraries of stopwords have been used during the data cleaning. Moreover, the dates and the tweets needed to be converted in numbers in order to be used during the machine learning part. SVD has been used to convert the tweet. Then, 10 machine learning techniques have been compared for the prediction of sentiment and of topic. Two studies have been done, with and without the taking into account the date of the tweets.

Data processing Languages, cleaning Data conversion Convert data in number (SVD) Machine Learning 10 methods compared Data visualization With/without tweets' date

Results

Let's take a look without taking into account the date of the tweets:

For the sentiment prediction, the best model is the kNN 7 neighbors with a F1 score of 0.459 without the time column in input. About the topic prediction, the best classifier is the tree but with a F1 score of 0.317. What is the difference with the results taking into account the date?

The best classifier for the sentiment prediction is the kNN 3 neighbors with a F1 score of 0.466 and for topic prediction, the best classifier is the tree with a F1 score of 0.99.
The results can be find into the tables below:

First table is without taking into account the date of tweets:

ModelAccuracy sentimentF1_score sentimentAccuracy topicF1_score topic
Bayes0.4550.2850.3100.147
Percepton0.3140.2880.3100.186
Multi-layer Perceptron0.4420.3700.3100.147
Tree0.3460.3440.3200.317
logistic Regression0.4550.2850.4120.294
kNN 3 neighbors0.3820.3760.3200.293
kNN 7 neighbors0.4690.4590.2900.267
kNN 15 neighbors0.4690.4530.3200.297
SVC0.4550.4040.3830.273
Random Forest0.4620.3670.3790.271

The second one take into account the date of tweets:

ModelAccuracy sentimentF1_score sentimentAccuracy topicF1_score topic
Bayes0.4590.2970.4090.292
Percepton0.4550.2850.2440.096
Multi-layer Perceptron0.2870.1280.2210.080
Tree0.4260.4350.9900.990
logistic Regression0.4550.2850.3100.147
kNN 3 neighbors0.4750.4660.9830.983
kNN 7 neighbors0.4520.4390.9830.983
kNN 15 neighbors0.4420.4190.9770.977
SVC0.4690.3410.3630.251
Random Forest0.4690.3720.7920.791

As you can see, the time column is very important for the topic prediction. In fact, most tweets about the same topic have been collected in short amount of time. This explains the important influence of this column on the topic prediction. The graphic below shows this phenomenon:

Blue: Apple, Green: Google, Yellow: Microsoft, Purple: Twitter