We draw inspiration from how humans process language. When people try to understand nuanced language they typically process multiple input sensor modalities to complete this cognitive task. It turns out the human brain has even a specialized neuron formation, called sagittal stratum, to help us understand sarcasm.
We use this biological formation as the inspiration for designing a neural network architecture that combines predictions of different models on the same text to construct robust, accurate and computationally efficient classifiers for sentiment analysis and study several different realizations. We have developed a systematic new approach to combining multiple predictors based on a dedicated neural network. Our approach is backed by a rigorous mathematical analysis of the combining logic along with state-of-the-art experimental results. We have also developed a heuristic-hybrid technique for combining models that relies on a heuristic idea of separating the set of models into one base and the remaining auxiliary, combined with appropriate Bayesian rules. Experimental results on a representative benchmark dataset and comparisons to other methods show the advantages of the new approaches.
Check our research paper "Can you tell? SSNet - a Sagittal Stratum-inspired Neural Network Framework for Sentiment Analysis" for context and details.
Proposed Combiner | Mean Accuracy (%) | Std |
---|---|---|
Neural Network Combiner | 93.87 | 0.1832 |
Bayesian Decision Rule Combiner | 93.63 | 0.2326 |
Heuristic-Hybrid Combiner | 93.73 | 0.3259 |
The project is written using the TensorFlow library and is compatible with TensorFlow 2.x. The dataset used for the experiments can be found at SLMRD which consists of 25K train reviews and 25K test reviews.
The data is downloadable as a .tar.gz
file which contains text files sorted into positive and negative reviews as well as metadata. For the training and inference code to run properly, imdb.vocab
should be copied to the ./models
folder (relative to the repository's main directory). If a folder named train
does not exist in the models
directory, it will need to be created; then, copy labeledBow.feat
from the dataset into the train
folder. Also copy (or move) the train/neg
and train/pos
folders from the downloaded data into train
. This will enable the model_1...
and model_2...
scripts to access the training and testing data. Additional preparation may be necessary before training the models or using them to make predictions on the data; see below.
Following is the directory structure:
The following is an overview of each file and folder in the repository, intended to reduce challenges with setup for new users. Where applicable, references to the paper and/or instructions for how to run the experiments are included.
The project consists of five modules: a) Split the dataset b) Training individual model c) Generating prediction from individual models d) Training the combiners e) Generating prediction from the combiner. Follow the below instructions to split the dataset and evaluate the models or combiners:
The project consists of three combiners: Neural Network Combiner, Bayesian Decision Rule Combiner and Heuristic-Hybrid Combiner. Each combiner has its own training and prediction accuracies. Following are the source codes for the combiners:
Use following instructions to run the combiner: 1) The combiner implementation consists of four files placed in the directory "combiners". The file "SSNet_predictions.py" expects 5K train data and probabilities predicted on tain and test data by all the four models. Currently all these required files are placed inside the data folder. Please note that file names may be little different, please rename if required before next step 2) Run "SSNet_predictions.py" 3) It could take a while to complete the three proposed methods but once done the output will produce all the accuracies 4) The output contains train (5K) accuracy and test accuracy (25K) 5) There would be minor changes in accuracy for neural network combiner