19

I am exploring tensorflow and would like to do sentiment analysis using the options available. I had a look at the following tutorial http://www.tensorflow.org/tutorials/recurrent/index.html#language_modeling

I have worked woth Naive Bayes Classifier, Maximum Entropy Algorithm and Scikit Learn Classifier and would like to know if there are any better algorithms offered by tensorflow. Is this the right place to start or are there any other options?

Any help pointing in the right direction would be greatly appreciated.

Thanks in advance.

Radhakrishnan
  • 266
  • 1
  • 2
  • 7

3 Answers3

15

A commonly used approach would be using a Convolutional Neural Network (CNN) to do sentiment analysis. You can find a great explanation/tutorial in this WildML blogpost. The accompanying TensorFlow code can be found here.

Another approach would be using an LSTM (or related network), you can find example implementations online, a good starting point is this blogpost.

Fematich
  • 1,588
  • 14
  • 26
3

I would suggest you try a character-level LSTM, it's been shown to be able to achieve state-of-the-art results in many text classification tasks one of them being sentiment analysis.

I wrote a pretty lengthy article that you can find here where I go through it's implementation in TensorFlow line by line. The result is a model that is less than 100mb in size and that achieves an accuracy of over 80% on a test set of 80,000 tweets.

Another approach that has proven to be very effective is to use a recursive neural network, you can read the paper from Stanford NLP Group here

Charles
  • 309
  • 3
  • 11
0

For me, the easiest tutorial to follow was: https://pythonprogramming.net/data-size-example-tensorflow-deep-learning-tutorial/?completed=/train-test-tensorflow-deep-learning-tutorial/

It walks you throughTensorFlow.train.AdamOptimizer().minimize(cost) and uses Sentiment140 dataset (from Stanford, ~1 mil examples of positive and negative sentiment)

aerin
  • 20,607
  • 28
  • 102
  • 140