Book Image

R Deep Learning Projects

Book Image

R Deep Learning Projects

Overview of this book

R is a popular programming language used by statisticians and mathematicians for statistical analysis, and is popularly used for deep learning. Deep Learning, as we all know, is one of the trending topics today, and is finding practical applications in a lot of domains. This book demonstrates end-to-end implementations of five real-world projects on popular topics in deep learning such as handwritten digit recognition, traffic light detection, fraud detection, text generation, and sentiment analysis. You'll learn how to train effective neural networks in R—including convolutional neural networks, recurrent neural networks, and LSTMs—and apply them in practical scenarios. The book also highlights how neural networks can be trained using GPU capabilities. You will use popular R libraries and packages—such as MXNetR, H2O, deepnet, and more—to implement the projects. By the end of this book, you will have a better understanding of deep learning concepts and techniques and how to use them in a practical setting.
Table of Contents (11 chapters)

Mining sentiment from Twitter

It's time to put our knowledge of different sentiment classification models in a more realistic scenario—Twitter sentiment analysis. 

As we mentioned in the introduction, sentiment analysis is of great interest for all companies that have a presence online (which is, well, lots of companies in many countries). It is also relevant for politicians, researchers, stock traders and others. 


Before using any service or API, be sure to review their terms of service and follow them! We do not encourage unlawful behavior in any way.

Connecting to the Twitter API

Luckily for us, there is a nice package in R to retrieve our Tweets: The library twitteR. First, there are a number of steps you need to follow:

  1. If you do not have one, create a Twitter account to be able to access their API.
  2. Go to and log in with your credentials. 
  3. Once logged in, click on Create New App.
  4. Put this as callback URL http://localhost:1410.
  5. Now go to Keys and Access Tokens...