Sample JAVA app for RRS

By for April 4, 2016

Report Abuse
JAVA app template for making real-time predictions using Azure ML APIs.
> **Note:** This is depreciated. #Build a Predictive App using JAVA and Azure ML# ##Overview## In this tutorial, we will walk through creating an JAVA app that can consume an Azure ML RRS API. For this example, we will be using the free version of NetBeans IDE. ##Create the Web Service API## While you can use any experiment you want, for this example we are using the "Income Prediction data" sample experiment from the Azure ML Gallery. We train the model, create a Predictive Experiment, then deploy it as a web service. We will call the Request-Response API created here from our JAVA app to predict if the person's income is <= 50K or > than 50K. ![https://az712634.vo.msecnd.net/tutorials/Sample-JAVA-app-for-RSS/income_pred.png][1] ##Create a Netbeans Project## First download the project from GitHub, then download Apache HttpComponents . Once you unzip everything into their respective folders, copy the HttpComponents lib folder into your main directory for the RSS app: ![https://az712634.vo.msecnd.net/tutorials/Sample-JAVA-app-for-RSS/netbeans_lib_proj.png][2] In NetBEans IDE, open the AzureML_RSSApp-master project. Build the project. ##The Application Code## Reading the JSON schema from the file rssJson.json: ![https://az712634.vo.msecnd.net/tutorials/Sample-JAVA-app-for-RSS/readjson.PNG][3] Reading the API key and API URL of Azure ML request response REST API: ![https://az712634.vo.msecnd.net/tutorials/Sample-JAVA-app-for-RSS/reeadapiinfo.PNG][4] Call REST API for retrieving prediction from Azure ML ![https://az712634.vo.msecnd.net/tutorials/Sample-JAVA-app-for-RSS/rrshttppost.PNG][5] Main program with the two command line arguments, JSON and API info file names: ![https://az712634.vo.msecnd.net/tutorials/Sample-JAVA-app-for-RSS/main.PNG][6] ##Test the Project## Update the apiinfo.txt file with your API key on your Studio Dashboard: ![https://az712634.vo.msecnd.net/tutorials/Sample-JAVA-app-for-RSS/test_prod.png][7] You also need to update the API end point in the APIinfo file with the API end point from the Studio Request/Response page: ![https://az712634.vo.msecnd.net/tutorials/Sample-JAVA-app-for-RSS/request_response1.png][8] ![https://az712634.vo.msecnd.net/tutorials/Sample-JAVA-app-for-RSS/request_response_long.png][9] To ensure the values in the json file match what the program is expecting, click test: ![https://az712634.vo.msecnd.net/tutorials/Sample-JAVA-app-for-RSS/test_button.png][10] And make sure the names in the test dialog match what is in the json file. You can also go into Studio, open your experiment, click on the visualize data and see the values for each field. ![https://az712634.vo.msecnd.net/tutorials/Sample-JAVA-app-for-RSS/view_dataset.png][11] The dataset opens in Excel: ![https://az712634.vo.msecnd.net/tutorials/Sample-JAVA-app-for-RSS/excel.png][12] Once built, you will need to run it with two parameters: java AzureML_RRSApp <jsonFilename> <apiInfoFilename> In a Windows command line, it looks like this: ![https://az712634.vo.msecnd.net/tutorials/Sample-JAVA-app-for-RSS/cmd.png][13] ##Summary## In this tutorial, we used NetBeans to create a simple JAVA app that can use Azure ML APIs to do real-time predictions. [1]: https://az712634.vo.msecnd.net/tutorials/Sample-JAVA-app-for-RSS/income_pred.png [2]: https://az712634.vo.msecnd.net/tutorials/Sample-JAVA-app-for-RSS/netbeans_lib_proj.png [3]: https://az712634.vo.msecnd.net/tutorials/Sample-JAVA-app-for-RSS/readjson.PNG [4]: https://az712634.vo.msecnd.net/tutorials/Sample-JAVA-app-for-RSS/reeadapiinfo.PNG [5]: https://az712634.vo.msecnd.net/tutorials/Sample-JAVA-app-for-RSS/rrshttppost.PNG [6]: https://az712634.vo.msecnd.net/tutorials/Sample-JAVA-app-for-RSS/main.PNG [7]: https://az712634.vo.msecnd.net/tutorials/Sample-JAVA-app-for-RSS/test_prod.png [8]: https://az712634.vo.msecnd.net/tutorials/Sample-JAVA-app-for-RSS/request_response1.png [9]: https://az712634.vo.msecnd.net/tutorials/Sample-JAVA-app-for-RSS/request_response_long.png [10]: https://az712634.vo.msecnd.net/tutorials/Sample-JAVA-app-for-RSS/test_button.png [11]: https://az712634.vo.msecnd.net/tutorials/Sample-JAVA-app-for-RSS/view_dataset.png [12]: https://az712634.vo.msecnd.net/tutorials/Sample-JAVA-app-for-RSS/excel.png [13]: https://az712634.vo.msecnd.net/tutorials/Sample-JAVA-app-for-RSS/cmd.png