knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%",
  message = FALSE, 
  warning = FALSE,
  error = FALSE
)

deepSentimentR

Project Status: Active – The project has reached a stable, usable state and is being actively developed. License: GPL-3 Travis build status Coverage status

The goal of deepSentimentR is to provide functionality to query, view and analyze sentiment datasets.

Installation

Prerequisites

install.packages("dplyr")
install.packages("keras")
keras::install_keras()

DeepSentimentR

You can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("adityamangal410/deepSentimentR")

Setup using Rocker

You can use rocker, which provides a set of docker images with R and different flavours of tidyverse, ML, geospatial etc.

Setup using rocker/ml

docker run -d --name rstudio -p 8787:8787 -e PASSWORD=<PASSWORD> -e USER=<USER> -v /Users/<USER>/Desktop:/Desktop rocker/ml

Go to http://localhost:8787 to login to the rstudio server.

devtools::install_github("adityamangal410/deepSentimentR")

Setup using rocker/tidyverse

Experimental steps

docker run -d --name rstudio -p 8787:8787 -e PASSWORD=<PASSWORD> -e USER=<USER> -v /Users/<USER>/Desktop:/Desktop rocker/tidyverse

Go to http://localhost:8787 to login to the rstudio server.

library(tidyverse)
system("python -V") # make sure you're using python3
#If Not, login to docker container and run following
#rm /usr/bin/python
#ln -s /usr/bin/python3 /usr/bin/python
#apt-get install curl
system("curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py")
system("python get-pip.py")
system("pip3 install virtualenv")
install.packages("keras")
keras::install_keras()
devtools::install_github("adityamangal410/deepSentimentR")

Example

Visualize polarity frequency based on given filters:

library(dplyr)
library(deepSentimentR)
data("sentiment140_train")
sentiment140_train %>% 
  freq_by_polarity(user_list = c("", "mcraddictal"), 
                   start_date_time = lubridate::as_datetime("2009-05-30"),
                   end_date_time = lubridate::as_datetime("2009-06-03"),
                   keyword_list = c(""))

Use pre-trained LSTM model using Glove Embeddings to make polarity predictions for the sample test dataset:

predict_polarity_keras(model_load_path = system.file("extdata",
                                                     "train_glove_lstm.rds",
                                                     package = "deepSentimentR",
                                                     mustWork = TRUE))

Check out full reference and examples at - https://adityamangal410.github.io/deepSentimentR/



adityamangal410/deepSentimentR documentation built on June 3, 2019, 6:15 p.m.