Deep Learning for Amazon Food Review Sentiment Analysis

Similar documents
System Implementation for SemEval-2017 Task 4 Subtask A Based on Interpolated Deep Neural Networks

Assignment 1: Predicting Amazon Review Ratings

Training a Neural Network to Answer 8th Grade Science Questions Steven Hewitt, An Ju, Katherine Stasaski

Model Ensemble for Click Prediction in Bing Search Ads

Twitter Sentiment Classification on Sanders Data using Hybrid Approach

Python Machine Learning

POS tagging of Chinese Buddhist texts using Recurrent Neural Networks

Lecture 1: Machine Learning Basics

A Simple VQA Model with a Few Tricks and Image Features from Bottom-up Attention

Semi-supervised methods of text processing, and an application to medical concept extraction. Yacine Jernite Text-as-Data series September 17.

Глубокие рекуррентные нейронные сети для аспектно-ориентированного анализа тональности отзывов пользователей на различных языках

Second Exam: Natural Language Parsing with Neural Networks

Attributed Social Network Embedding

A Vector Space Approach for Aspect-Based Sentiment Analysis

Unsupervised Learning of Word Semantic Embedding using the Deep Structured Semantic Model

A Case Study: News Classification Based on Term Frequency

arxiv: v5 [cs.ai] 18 Aug 2015

Netpix: A Method of Feature Selection Leading. to Accurate Sentiment-Based Classification Models

(Sub)Gradient Descent

Rule Learning With Negation: Issues Regarding Effectiveness

Modeling function word errors in DNN-HMM based LVCSR systems

A study of speaker adaptation for DNN-based speech synthesis

Prediction of Maximal Projection for Semantic Role Labeling

Modeling function word errors in DNN-HMM based LVCSR systems

Probabilistic Latent Semantic Analysis

CS Machine Learning

Syntax Parsing 1. Grammars and parsing 2. Top-down and bottom-up parsing 3. Chart parsers 4. Bottom-up chart parsing 5. The Earley Algorithm

arxiv: v1 [cs.cl] 20 Jul 2015

Using dialogue context to improve parsing performance in dialogue systems

Ask Me Anything: Dynamic Memory Networks for Natural Language Processing

A Neural Network GUI Tested on Text-To-Phoneme Mapping

Linking Task: Identifying authors and book titles in verbose queries

Detecting English-French Cognates Using Orthographic Edit Distance

Cultivating DNN Diversity for Large Scale Video Labelling

Artificial Neural Networks written examination

Semantic Segmentation with Histological Image Data: Cancer Cell vs. Stroma

CS 446: Machine Learning

Introduction to Ensemble Learning Featuring Successes in the Netflix Prize Competition

The stages of event extraction

arxiv: v1 [cs.cv] 10 May 2017

Predicting Student Attrition in MOOCs using Sentiment Analysis and Neural Networks

Learning Structural Correspondences Across Different Linguistic Domains with Synchronous Neural Language Models

arxiv: v1 [cs.cl] 2 Apr 2017

Calibration of Confidence Measures in Speech Recognition

A JOINT MANY-TASK MODEL: GROWING A NEURAL NETWORK FOR MULTIPLE NLP TASKS

A New Perspective on Combining GMM and DNN Frameworks for Speaker Adaptation

Truth Inference in Crowdsourcing: Is the Problem Solved?

Learning From the Past with Experiment Databases

Word Segmentation of Off-line Handwritten Documents

ADVANCED MACHINE LEARNING WITH PYTHON BY JOHN HEARTY DOWNLOAD EBOOK : ADVANCED MACHINE LEARNING WITH PYTHON BY JOHN HEARTY PDF

Rule Learning with Negation: Issues Regarding Effectiveness

Learning Methods in Multilingual Speech Recognition

Softprop: Softmax Neural Network Backpropagation Learning

QuickStroke: An Incremental On-line Chinese Handwriting Recognition System

arxiv: v4 [cs.cl] 28 Mar 2016

Switchboard Language Model Improvement with Conversational Data from Gigaword

Residual Stacking of RNNs for Neural Machine Translation

Deep Neural Network Language Models

A deep architecture for non-projective dependency parsing

Autoregressive product of multi-frame predictions can improve the accuracy of hybrid models

A Comparison of Two Text Representations for Sentiment Analysis

arxiv: v1 [cs.lg] 15 Jun 2015

Postprint.

Machine Learning and Development Policy

Knowledge Transfer in Deep Convolutional Neural Nets

Product Feature-based Ratings foropinionsummarization of E-Commerce Feedback Comments

MYCIN. The MYCIN Task

Semantic and Context-aware Linguistic Model for Bias Detection

HIERARCHICAL DEEP LEARNING ARCHITECTURE FOR 10K OBJECTS CLASSIFICATION

CS 598 Natural Language Processing

Extracting Opinion Expressions and Their Polarities Exploration of Pipelines and Joint Models

Robust Speech Recognition using DNN-HMM Acoustic Model Combining Noise-aware training with Spectral Subtraction

arxiv: v2 [cs.ir] 22 Aug 2016

Beyond the Pipeline: Discrete Optimization in NLP

OCR for Arabic using SIFT Descriptors With Online Failure Prediction

METHODS FOR EXTRACTING AND CLASSIFYING PAIRS OF COGNATES AND FALSE FRIENDS

CLASSIFICATION OF TEXT DOCUMENTS USING INTEGER REPRESENTATION AND REGRESSION: AN INTEGRATED APPROACH

Human Emotion Recognition From Speech

OPTIMIZATINON OF TRAINING SETS FOR HEBBIAN-LEARNING- BASED CLASSIFIERS

Indian Institute of Technology, Kanpur

Extracting and Ranking Product Features in Opinion Documents

Optimizing to Arbitrary NLP Metrics using Ensemble Selection

The Internet as a Normative Corpus: Grammar Checking with a Search Engine

Probing for semantic evidence of composition by means of simple classification tasks

Ensemble Technique Utilization for Indonesian Dependency Parser

Natural Language Processing. George Konidaris

Module 12. Machine Learning. Version 2 CSE IIT, Kharagpur

11/29/2010. Statistical Parsing. Statistical Parsing. Simple PCFG for ATIS English. Syntactic Disambiguation

AP Statistics Summer Assignment 17-18

CHAPTER 4: REIMBURSEMENT STRATEGIES 24

Dropout improves Recurrent Neural Networks for Handwriting Recognition

Dublin City Schools Mathematics Graded Course of Study GRADE 4

Dialog-based Language Learning

Chinese Language Parsing with Maximum-Entropy-Inspired Parser

Reducing Features to Improve Bug Prediction

On the Formation of Phoneme Categories in DNN Acoustic Models

Parsing of part-of-speech tagged Assamese Texts

Framewise Phoneme Classification with Bidirectional LSTM and Other Neural Network Architectures

THE ROLE OF DECISION TREES IN NATURAL LANGUAGE PROCESSING

Memory-based grammatical error correction

Transcription:

000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 048 049 050 051 052 053 Deep Learning for Amazon Food Review Sentiment Analysis Jiayu Wu, Tianshu Ji Abstract In this project, we study the applications of Recursive Neural Network on sentiment analysis tasks. To process the raw text data from Amazon Fine Food Reviews, we propose and implement a technique to parse binary trees using Stanford NLP Parser. In addition, we also propose a novel technique to label tree nodes in order to achieve the level of supervision that RNN requires, in the context of the lack of labeling in the original dataset. Finally, we propose a new model RNNMS (Recursive Neural Network for Multiple Sentences), and have better results than our baseline in terms of every metrics we consider. 1 Introduction Sentiment Analysis is an important task in NLP. Its purpose is to extract a single score from text, which makes it more convenient to analyze a large corpus of text. Various methods has been used to solve sentiment analysis problems, including bag-of-words and n-grams, and the arrival of deep learning, especially recursive neural network, provides a novel and powerful way to extract sentiment from text data. Recursive neural network has been shown to have a stellar performance using Stanford Sentiment Treebank data [1]. However, many of text datasets are not as well labeled as Stanford Sentiment Treebank. For example, the data we have only has one label for each review which is composed of multiple sentences. Therefore, the goal of our project is to test whether recursive neural network is still effective with insufficient tree labeling. Moreover, most RNNs are designed to only consider one single sentence as input, and thus we propose RNNMS, Recursive Neural Network for Multiple Sentences, to handle multiple sentences at once. 2 Background and Related Work Recent work has been focused on other complicated RNN models such as recursive neural tensor network [1], which is robust in detecting negating negatives, and Tree LSTM[2], which has the idea of forget gate inherited from LSTM. is a hot model and certainly worth our studies in a project. Looking at last years project [3], the accuracy of that was 59.32% to 63.71%, depending on different Recursive Neural Network models. They developed vanilla one hidden layer, two hidden layer recursive neural networks and RNTN. In our project, we achieved 10% more than their result, which is a significant improvement. Better tree parser and amplify labeling internal nodes techniques are attributed to our better result. Meanwhile, Stanford TreeBank, due to the strong supervision, that is to say, thoroughly labeled internal nodes, achieved very good test accuracy (more than 80%). It is so far the best data set which to be used for Recursive Neural Network. On the other hand, we can assume that lack of labeling is one of the big challenges for Recursive Neural Network. Back to the Kaggle challenge, although there is no current winner accuracy right now, the data set and the question were actually drawn from a paper coming from Stanford.[4] Though, in their paper, 1

054 055 056 057 058 059 060 061 062 063 064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079 080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095 096 097 098 099 100 101 102 103 104 105 106 107 the main challenge was not sentiment analysis, their highest test accuracy was about 40% in their studies of users tastes and preferences changing and evolving over time. This low accuracy also showed that this was a challenging data set to analyze on. 3 Approach 3.1 Dataset 3.1.1 Data preprocessing The Amazon Food Review dataset has 568, 454 samples. 52268 reviews have a score of 1, 29769 reviews have a score of 2, 42640 reviews have a score of 3, 80655 reviews have a score of 4, and 363122 reviews have a score of 5. However, we found that it is difficult to distinguish reviews with score 4 and reviews with score 5, and same difficult for reviews with score 1 and reviews with score 2. For example, consider the following review: good flavor! these came securely packed... they were fresh and delicious! i love these Twizzlers! This review turns out to have a score of 4 while it would also make sense if the review had a score of 5. Therefore, our solution is to binarize the labels to positive and negative by aggregating score 4 and 5 as positive, score 1 and 2 as negative, and ignore samples with score 3 since we are more interested in reviews with a clear attitude. After we binarizing review scores, we notice the dataset is quite imbalanced, i.e. about 80% of the reviews are positive. If we have a classifier which would always predict a review as positive, then it is able to easily achieve 80% accuracy. To solve this problem, we use undersampling technique. We randomly drop positive reviews to make the number of positive reviews are roughly the same as that of negative reviews. 3.1.2 Dataset stats Before we start building deep learning models, we first examine the features of our dataset in order to construct an appropriate model. Using twitter sentiment words [5], we can obtain sentiment label for each word in our reviews. We want to take a look at the difference of positive reviews and negative reviews from the word-level perspective. The left figure is the summary for negative reviews, and the right for positive reviews. Both of the figures have three categories. The first category is the number of reviews that contain more negative words than positive ones, the second is the number of reviews that contain equally many positive and negative words, and the last one is the number of reviews that contain more positive words than negative ones. 2

108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 We notice that while most of the positive reviews have more positive words than negative words, it is surprising to find that even around half of the negative reviews have more positive words than negative words. The stats we just show are important because they show that doing sentiment analysis only on the word level may not work well for the dataset we have. Therefore, the baseline we have that just essentially uses bag-of-word model is not likely to perform very well. We need some model that is able to look at the bigger picture, that is to take sentence structure into consideration. 3.1.3 Tree parser One of the most important parts of our project is to construct binary trees, in order to feed our Recursive Neural Networks. Stanford NLP Parser is a powerful tool to parse sentences to trees based on a specified NLP model. We choose exhaustive PCFG(Probabilistic Context-Free Grammars) parser as our parser to process the reviews. The problem of the PCFG parser is that the tree returned is not always a binary tree. An internal node may have more than two children. Since our model can only handle two children s hidden layer output, then we need to convert trees into their binary form. Therefore, we add the TreeBinarizer class in processresults() of ParseFiles class, and then we can have binary trees. However, there is still one more problem of these trees. Some internal nodes may only have one child, since, again, we need each internal node to have two children for our model. For example, NN man. To solve this problem, we employ the following technique: for each internal node that has only one child, we delete this node and elevate its child one level up. For example, suppose we have NP thenn and NN man, notice that NP node has two children while NN node has only one child. In this case, we treat the above the structure as NP the man. Now we have binary trees ready. The following figure is a histogram of tree depth distribution. We find that most of the trees we generate from reviews have a depth between 15 and 20. Notice that if a tree is too deep, not only the model may not perform well but also it takes too long to train the model using this tree. Therefore, we prune the trees that have a depth more than 20. Another potential problem of the tree is the lack of labeling. Training Recursive Neural Network usually needs comprehensive supervision, namely every node is labeled. However, given the nature of our dataset, one review, composed of multiple trees, only has one label. It may be very difficult for RNN to learn well with such low-level supervision. Therefore, in order to increase the level of supervision in our model, we first label words located at the leaf level. With the help with twitter sentiment words [5], we are able to label the words as positive, negative or neutral. However, there are still about half of the nodes that are not labeled. It is difficult to label each node, or phrase, due to the lack of phrase sentiment banks. Thus we propose a novel technique to label the internal nodes without laborious human labeling over thousands even millions of nodes. For each internal node, we check its two children s label: if their label is identical, then we set the internal 3

162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 node s label to the same label; if their label is not identical, then we are not sure about the node s sentiment and we just set the label to be neutral. Notice that although we set some internal nodes label to be neutral, the model that we use actually will ignore all neutral labels and only considers positive/negative labels when calculating loss function. 3.2 Models We use a one hidden-layer Recursive Neural Network as our model. In most previous work, RNN is fed with single sentences. However, we want to feed reviews(paragraphs) to RNN. Therefore, we propose the model RNNMS (Recursive Neural Network for Multiple Sentences). We first define the hidden layer: For the review root, we have For other nodes, we have Then we define the output layer: For the review root, we have For other nodes, we have = tanh(( 1 N N i=1 child i )W (r) + b (r) ) (1) = max([ left, h(1) right ]W (1) + b (1), 0) (2) ŷ = softmax( U (r) + b (r) s ) (3) ŷ = softmax( U (1) + b (1) s ) (4) h R 1 d, ŷ R 1 C, W (1) R 2d d, b (1) R 1 d, U (r) R d C, b (r) s R 1 C, U (1) R d C, b (1) s R 1 C. And we choose the embedding size d = 50, and the label size C = 2. 4

216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 Finally, we define the loss function: J = βce(y r, ŷ r ) + ( all nodes with labels CE(y, ŷ)) + l2( W (r) ij + W (1) ij + U (r) ij + U (1) ij ) β is the weight of the review root s cross entropy loss. We amplify the effect of the review root by setting β = the number of all nodes with a positive/negative label - 1. We increase the weight of the review root because due to the lack of labeling for internal nodes, we need to make good use of the review label and after all what we really care about is the prediction accuracy at the review root level. Recursive neural network is the way of using the same set of weight and applying recursively on the same structure. Recursive neural network has been used as a useful tool in natural language processing, especially in sentiment analysis, because it processes the sentence as how a human understands a sentence. There are two major differences between our RNNMS and the naive RNN. First, at review root level, we average the hidden layer output of all its children. This technique is similar to averaging every word s vector in a sentence when we want to do sentiment analysis on a single sentence. We incorporate the idea of bag-of-sentence to the master root level of our model because we believe the average value can be a good generalization of the sentences it contain. For example, if a positive review contains four sentences, and all sentences are positive, then the average is likely to be also treated as positive. Even there is one negative sentence, the averaging operation can still put the review level hidden layer output to the positive side. Second, we have a different output layer for review root than that for all other nodes. The reason behind this is that while the RNN model assumes there exists a recursive grammatical structure for each sentence, the relationship between the review and sentences is not captured by any recursive grammatical rules. Therefore, we need a different pair of U and bs to fit the review root level s output. 4 Experiments & Results 4.1 Baseline Our baseline is a Naive Bayes classifier and we use the average of all word vectors of a review as the feature vector for a review. precision recall f1 negative 0.66 0.73 0.69 positive 0.72 0.65 0.69 average 0.69 0.69 0.69 The results show that how well the baseline with a basic bag-of-word model can perform. Notice that the baseline actually performs very well. Due to the nature of the problem, the sentiment analysis of single sentence like movie reviews, accuracy never reached above 80% for 7 years [6]. We think the reason behind this is that while movie reviews have a lot of sarcasm, which is very difficult for any model to grasp, amazon food reviews are much more straight forward, and thus most of the sentiments are expressed directly at the word level. For example, a user may write a lot of positive words to say a food is good. It is possible to judge a food review s sentiment only by identifying positive words in a food review,. However, it is usually not enough to predict a movie review s (5) 5

270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 sentiment only by looking for positive or negative words. Therefore, given the nature of our dataset, the baseline actually sets a high bar for our RNNMS model. Unlike many other models using bag-of-word or n-gram, Recursive Neural Network is able to learn to grasp the semantic structure of a sentence because it considers the semantic composition of a sentence during training. Therefore, Recursive Neural Network is expected to perform better than character-level n-gram models and bag-of-word models for sentiment analysis task. 4.2 RNNMS results For training our model, we initialize the embedding matrix using 50 dimensional GloVe word vectors trained by twitter data because we think tweets are both semantically and grammatically similar to online food reviews. Here is the best result from our RNNMS with learning rate = 0.1 and l2 regularization = 0.01. precision recall f1 negative 0.72 0.79 0.76 positive 0.77 0.70 0.73 average 0.75 0.75 0.74 The results show that all metrics of our RNNMS outperform the baseline we have. The 6% boost of average accuracy may be the result of more understanding of the grammatical structure of a review. 4.3 Hyperparameter tuning (a) lr=0.1, l2=0.005 (b) lr=0.1, l2=0.01 (c) lr=0.1, l2=0.02 The above three plots are train accuracy and validation accuracy vs. epoch for three different pairs of learning rate and l2 regularization. Notice that in (a), train accuracy rises to almost 1 but the validation accuracy first hits above 0.7 but later drops and remains around 0.65, which indicates the overfitting problem due to a small l2 regularization parameter. In (c), both train accuracy and validation accuracy grows very slow and plateau at around only 0.6, which indicates the underfitting problem due to a large l2 regularization parameter. For the pair with best test accuracy, which is lr=0.1 and l2=0.01, we see that both the train accuracy and validation accuracy goes up significantly since epoch 5 and plateau since epoch 20. Therefore it shows that our model converges quickly and does not require a large number of training epochs. It is possible that the reason behind this is that a lot of food reviews are quite similar, and thus when given similar training reviews, the model is able to learn very fast. 6

324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 4.4 Activation function comparison For the review root, we change the non-linearity to and = tanh(( 1 N = relu(( 1 N = sigmoid(( 1 N The test accuracy for each case are as follows: N i=1 N i=1 child i )W (r) + b (r) ) (6) child i )W (r) + b (r) ) (7) N i=1 child i )W (r) + b (r) ) (8) tanh function has the highest test accuracy. Therefore, we chose tanh function in our best model. An insight that we got from piazza is that ReLU and sigmoid both saturate at 0 on the negative side, whereas tanh saturates at -1. Thus, if a weight gets multiplied by the output of a tanh, the size of the weight matters for negative values of the input to the tanh. It does not matter for any negative ReLU inputs and for sufficiently large sigmoid inputs in absolute value. [7] 5 Conclusion RNNMC performs better than the baseline. Even with insufficient labeling of trees, RN- NMC is still able to outperform in every metrics we have than the baseline naive bayes classifier using averaged word vectors as input features, which means that understanding phrase-level structure does help sentiment analysis task. For recursive neural network, labeling every node is very important. While this model can achieve as high as above 80% accuracy using Stanford Sentiment Tree Bank dataset, Our results show that without sufficient labeling, this model is not able to achieve an accuracy above 80%, which means RNN family needs strong supervision. However, most of the online reviews and other documents only have very limited labels, therefore our results are meaningful because it shows that even without sufficient labeling of tree nodes, it stills performs well. Moreover, we have proposed and tested a novel technique in order to increase the level of supervision by adding label to some nodes of a tree. The recursive hidden layer should only be shared among tree nodes that are intrinsically similar, that is to see we probably should not use the same recursive hidden layer for aggregating sentences for the review root node. The reason is that the relationship between sentences, as we think, should be intrinsically different than that between phrases and words. Therefore, when we design recursive neural network, we should think about whether the structure we model should have a recursive property. Otherwise, we need to design a different hidden layer and output layer for the review root level, like what we did in our RNNMS. 7

378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 6 Reference 1. Richard Socher, Alex Perelygin, Jean Y Wu, Jason Chuang, Christopher D Manning, Andrew Y Ng, and Christopher Potts. Recursive deep models for semantic compositionality over a sentiment treebank. In Proceedings of the conference on empirical methods in natural language processing (EMNLP), volume 1631, page 1642. Citeseer, 2013. 2. Kai Sheng Tai, Richard Socher, and Christopher D. Manning. Improved semantic representations from tree-structured long short-term memory networks. CoRR, abs/1503.00075, 2015. 3. Ye Yuan and You Zhou. Twitter Sentiment Analysis with Recursive Neural Networks. http://cs224d.stanford.edu/reports/yuanye.pdf 4. J. McAuley and J. Leskovec. From amateurs to connoisseurs: modeling the evolution of user expertise through online reviews. WWW, 2013. 5. Jeffrey Breen. twitter-sentiment-analysis-tutorial-201107. https://github.com/jeffreybreen/twitter-sentiment-analysis-tutorial- 201107/blob/master/data/opinion-lexicon-English 6. Bo Pang and Lillian Lee. Seeing stars: Exploiting class relationships for sentiment categorization with respect to rating scales. In Proceedings of the 43rd Annual Meeting on Association for Computational Linguistics, pages 115124. Association for Computational Linguistics, 2005. 7. Piazza Discussion 8