Skip to content

Project in R developing a restaurant review classifier that makes predictions as positive or negative integrated with a Rest API in Node.js.

Notifications You must be signed in to change notification settings

rd-coutinho/NLP-in-R-with-Node.js-Rest-API

Repository files navigation

A Rest API in Node.js with Express developed to run a NLP (Natural Language Processing) classifier. The model is based on a dataset of 1000 restaurant reviews labeled as either 0 (a negative review) or 1 (positive review) trained considering the bag of words model transforming each review in order the supervised machine learning algorithm to capture the correlations between words (to lower case, removing numbers, punctuation, stopwords, stemming and so on) and make the prediction.

The model was created in R building a Random Forest algorithm integrated with Node.js to have a Rest API with R-Script data.

GET

Return the machine lerning classification as being 0 (negative review) or 1 (positive review).

POST

Requires a JSON content, like below

{
"new_review": "I really love this restaurant!!!"
}

Example

In this example, we write a positive review as a JSON Content and make a POST request, getting a response with the prediction made by algorithm (correctly predicted class 1, being a positive review).

Installation

With Node.js already installed, execute the commands below to download and install the dependencies and run the app:

npm install express -save
npm install r-script --save
Or npm install to install all dependencies used in this project.

node app.js

R Packages

All the necessary R packages used to build the model:

install.packages('tm')
install.packages('SnowballC')
install.packages('caTools')
install.packages('randomForest')

About

Project in R developing a restaurant review classifier that makes predictions as positive or negative integrated with a Rest API in Node.js.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published