VR Gameplay — Sentiment Analysis: Part 3

Deploy Machine Learning APIs on Heroku

Widnu
3 min readSep 18, 2020

1.1 Deploy APIs on Heroku

Heroku enables developers to build, run, and operate applications entirely in the cloud. We can map the code from git repository to Heroku deployment and deploy it as public services, Then we use the other applications to call the services via the Internet.

1. Register and log in the Heroku website: https://www.heroku.com/.

2. Create new application.

Figure 14. Select Create new app option.

3. Enter the App name and region, then click Create app button

Figure 15. Fill application’s details

4. In the Deploy tab, we do not need to create a pipeline.

5. Change the Deployment method to GitHub.

6. Search the repository of our APIs, which is py_sentiment_analysis.

7. Click the Connect button.

Figure 16. Connect to GitHub.

8. We do not need to enable the automatic deployment.

9. Select the branch as master and click the Deploy Branch button.

Figure 17. Deploy the master branch.

10. The successful deployment should display the following screenshot.

Figure 18. Successful deployment.

1.2 Test the APIs on Heroku Server

1. Install Postman. We can choose the free plan for the installation.

a. https://www.postman.com/pricing/

2. Open Postman from the start menu.

3. Create a new request.

4. Fill the request’s details and click Send button:

Method = POSTEndpoint = https://ml-sentiment-api.herokuapp.com/api/v2/resources/sentiment/vaderBody = rawRequest type = JSONRequest body = {“sentence”: “God gives us dreams at night so that we can turn them into reality during the day. So have faith and move ahead.”,“emotion”: “”}
Figure 19. Send request via Postman.

5. The APIs on Heroku should respond the result successfully.

Figure 20. Receive response from the APIs.

1.3 Available API Endpoints

The following endpoints are published on Heroku server and they can be called by using the same request parameters. The different is the NLTK analysis methods regarding the trained model, which all of them are listed in http://www.nltk.org/nltk_data/. For this project, we used Vader lexicon with neutral tone.

Conclusion

In this story, we deploy and test the APIs on Heroku to predict the tone of sentences by using NLTK Vader model.

Next

We will set up and build Android Archive (AAR) plug-in. This is the plug-in for use in Unity 3D.

--

--