I had a meeting with Dr. Carpuat today where we went over the ablation experiments and discussed what could have impacted some of the results. By the end of the meeting, the objectives for my summer internship became more clear.

Rather than building a regression model myself, I would just use the weka baseline model to test my neural network model against. Dr. Carpuat referred my to PyTorch, a library in python for neural network development, which I will be using in my project.

My objectives are as follows:

  • Work with the lexicons used in the baseline model to see how they are implemented
    • How do they create the x vector (is it just 0’s and 1’s)
  • Work with PyTorch to understand neural networks
  • Create a neural network model (not too complex, 1 hidden layer, etc.) and see how it compares to the baseline model
  • Continue building upon the model to see how well it can compete with the baseline model
    • Adding features, layers, etc.


The main thing I had to do today was to get the word ngrams and character ngrams feature set to work to finish the ablation experiments. While I wasn’t able to get it to work in the past, I realized the problem almost immediately today.

The index it was trying to filter was set to 3 (as default), which means the only word it would ever be trying to filter into different word ngrams and character ngrams would be the emotion. By changing the index to 2, it would then filter the tweet.

The final ablation table


As shown by the table, the overall best performing combination was word embeddings with all the lexicons. Using the word ngrams and character ngrams alongside the other filters proved to be a little less accurate, possibly due to overfitting.



Finally Weka!

It took so long to get Weka to work the way I wanted it to, but now it seems simpler than I thought. Before Friday, I needed to run ablation experiments to determine the importance of certain features in the baseline system. Saif Mohammad tested with word ngrams (WN), character ngrams (CN), word embeddings (WE), and lexicons (L); he used 11 lexicons, I will only test on 10 as I don’t have access to one of them.

Back in Weka, the way to correctly run models is to keep the preprocessing filter set to “None”, and then coming back to the classification tab to use the correct filter set and classifier. The configuration below describes one of the tests I ran.

weka.filters.MultiFilter -F "weka.filters.unsupervised.attribute.TweetToEmbeddingsFeatureVector -I 2 -B C:/Users/amanj/wekafiles/packages/AffectiveTweets/resources/w2v.twitter.edinburgh.100d.csv.gz -S 0 -K 15 -L -O" -F "weka.filters.unsupervised.attribute.TweetToLexiconFeatureVector -I 2 -A -D -F -H -J -L -N -P -Q -R -T -U -O" -F "weka.filters.unsupervised.attribute.TweetToSentiStrengthFeatureVector -I 2 -U -O" -F "weka.filters.unsupervised.attribute.TweetToSparseFeatureVector -M 0 -I 1 -Q 4 -D 3 -E 5 -L -F -G 0 -I 0" -F "weka.filters.unsupervised.attribute.Reorder -R 5-last,4"

This test used word embeddings and all the lexicons (SentiStrength is a lexicon that is it’s own filter), and use the LibLINEAR classifier with L2 regularized and L2 loss. I ran the other tests the same way, by removing all lexicons except for the one I was testing for, or only using the word embeddings filter.

After running the tests, the ablation experiments were was mostly done.AblationTable1
Note: The scores calculated are the Pearson correlation scores.

Tomorrow I will finish running experiments with word ngrams and character ngrams, and then running those filters with word embeddings or lexicons. Lastly, there will be the final model which uses all the filters to look at how the model does when using all the features.

I also finished reading the EmoInt paper. It made me familiar with their process, and furthermore gave me ideas for applications for the regression/deep learning model I will create.



The paper, Emotion Intensities in Tweets, authored by Saif M. Mohammad and Felipe Bravo-Marquez, talks about how they went about creating the data and building their system on Weka. Two key things came out of reading this paper.

  1. I was able to think about potentially creating my own data
  2. I now know which filters were used by them to create the model

It would be interesting to gather data in the same way they did. While it may not be as big of a research application, it would be an interesting thing to learn for future projects (the use of best-worst scaling, etc.).

More importantly, now that I know the filters they used for their model, I can recreate it in Weka to have a baseline system to test against when building my own regression model and Deep Learning model


NLTK is a really great library for doing natural language processing. Instead of working on my model, I decided to take the time and learn about NLTK, so I can use it (and perhaps use it with GraphLab Create later).

NLTK comes with a variety of tools, such as tokenization and POS tagging. Tokenization can be done in sentences or words, which splits up a paragraph into individual sentences, or a sentence (or longer text) into words, to then analyze.

There are a couple reasons for me to use NLTK. First, it will make a lot of preprocessing easy for me, such as filtering out stop words (words that do not have meaning in collecting data, such as “as”, “what”, “that”.

from nltk.corpus import stopwords

This allows you to create a set of all the stop words in the English language (the words recognized by NLTK at least). From there, you can simply pass the sentence through, and take out any word that is found in the stop word set.

Additionally, there are methods in NLTK that can create a parse tree, where you can see what objects are related to other objects. This is important in establishing relationship between objects in a sentence, so you (the computer) can figure out what the sentence is about.

I haven’t gotten through the entire “course” of what can be done with NLTK, but once I have done that, I can begin trying to use GraphLab Create’s linear regression model alongside NLTK to create my system. Until then, I plan to continue researching other potential libraries I can use for my system, and reading the paper that Dr. Carpuat wants me to read (link in Resources)


I took some time away from the TweetToSparseFeatureVector today and focused on getting scores for all the different training data sets: Anger, Fear, Joy, and Sadness. I ran my MultiFilter on Fear, Joy, and Sadness, since I had already ran it on Anger.

=== Anger Summary ===

Correlation coefficient 0.625
Kendall's tau 0.4454
Spearman's rho 0.6155
Mean absolute error 0.1069
Root mean squared error 0.1358
Relative absolute error 76.1346 %
Root relative squared error 79.0147 %
Total Number of Instances 760

=== Fear Summary ===

Correlation coefficient 0.6216
Kendall's tau 0.4382
Spearman's rho 0.6087
Mean absolute error 0.1275
Root mean squared error 0.1575
Relative absolute error 77.1929 %
Root relative squared error 78.3684 %
Total Number of Instances 995

=== Joy Summary ===

Correlation coefficient 0.636
Kendall's tau 0.4603
Spearman's rho 0.6435
Mean absolute error 0.1348
Root mean squared error 0.1688
Relative absolute error 73.702 %
Root relative squared error 77.5147 %
Total Number of Instances 714

=== Sadness Summary ===

Correlation coefficient 0.7094
Kendall's tau 0.5229
Spearman's rho 0.7116
Mean absolute error 0.1142
Root mean squared error 0.1431
Relative absolute error 67.2283 %
Root relative squared error 70.4165 %
Total Number of Instances 673

The next step was to compare this system to the Weka Baseline system created by the task creators. If my system is on par (or better) than the Weka Baseline system, I can then use it to compare my Linear Regression and eventually Deep Learning models to.

System comparison:

System Avg. Pearson Avg. Spearman Anger Pearson Anger Spearman Fear Pearson Fear Spearman Joy Pearson Joy Spearman Sadness Pearson Sadness Spearman
Weka Baseline System 0.648 0.641 0.639 0.615 0.652 0.635 0.654 0.662 0.648 0.651
My System (4 filters) 0.648 0.6448 0.625 0.6155 0.6216 0.6087 0.636 0.6435 0.7094 0.7116

As shown in the table, my system is not that far off in the different emotions (in fact, it performed better than the Weka Baseline system for Sadness), and the average Pearson and Spearman scores are higher. While I could use this system to test my future models on, I want to try one more time and add the TweetToSparseFeatureVector, as I think it will benefit my system.

Additionally, today I looked into some tools that I could use when building my future Sentiment Analysis model. I found a python module called Natural Language Tool Kit (NLTK) which makes NLP in python very simple. There are some other cool tools such as H2O.ai, and Turi’s GraphLab Create (which I have used in the past).

By Friday, I hope to have the preliminary testing with Weka done, and then hopefully I can get started with my own model next week.


I had already made a Multi-Filter model for the test data, so I decided to try some of the other Filters.

The TweetToSparseFeatureVector, provided by the AffectiveTweets package on Weka, allows for a variety of different features, such as Character N-Grams, Word N-Grams, POS Tags, etc. The first TweetToSparseFeatureVector I tried was

weka.filters.unsupervised.attribute.TweetToSparseFeatureVector -M 2 -I 3 -R -Q 3 -A -D 3 -E 5 -L -O -F -G 2 -I 2

which ran with these settings:


However, Weka was not working the way it was supposed to (or rather I could not get it to make models for the things I needed), so I created just the filters I would use, so I could perhaps test it on the UMD machines or see if my Mentor Dr. Carpuat would know what to do with them.

  • weka.filters.unsupervised.attribute.TweetToSparseFeatureVector -M 2 -I 3 -R -Q 3 -A -D 3 -E 5 -L -O -F -G 2 -I 2 Word N-Grams, Character N-Grams, Negations, POS Tags, Brown Clusters
  • weka.filters.unsupervised.attribute.TweetToSparseFeatureVector -M 2 -I 3 -R -L -O Only Negations
  • weka.filters.unsupervised.attribute.TweetToSparseFeatureVector -M 2 -I 3 -A -D x -E y -L -O Only Character N-Grams
  • weka.filters.unsupervised.attribute.TweetToSparseFeatureVector -M 2 -I 3 -Q 3 -L -O Only Word N-Grams
  • weka.filters.unsupervised.attribute.TweetToSparseFeatureVector -M 2 -I 3 -A -D x -E y -Q 3 -L -O Word N-Grams and Character N-Grams
  • weka.filters.unsupervised.attribute.TweetToSparseFeatureVector -M 2 -I 3 -A -D x -E y -Q 3 -L -O Word N-Grams, Character N-Grams, POS Tags
  • weka.filters.unsupervised.attribute.TweetToSparseFeatureVector -M 2 -I 3 -R -A -D x -E y -Q 3 -L -O Word N-Grams, Character N-Grams, Negations

I plan on building my Sentiment Analysis system in Python, rather than Java, and I want to use the following Features: Word N-Grams, Character N-Grams, Negations, POS Tags, and Brown Clusters. Later I want to build on the system using some of the higher-end Filters that Weka provides (or the Python counterpart), and hopefully some other ones too.

Note: x, y, and z are placeholders for the Integer value that can be put there.

Note2: Here are the different configurations for the Filter

  • -I TextIndex (This is the first I in the config)
  • -R Negation
  • -A Character N-grams -D Min -E Max
  • -I MaxDim for clustNGram (This is the last I in the config)
  • -F Frequency Weights
  • -G MaxDim for POS N-gram
  • -L toLowerCase
  • -Q Word N-gram MaxDim
  • -O CleanToken
  • -M minAttDocs