Permalink
Fetching contributors…
Cannot retrieve contributors at this time
125 lines (70 sloc) 7.25 KB

Watson Hands On Labs - Personalized Recommendations

This lab was originally created as a part of the World of Watson event in May 2015.

The labs cover several Watson Services that are available on IBM Bluemix to build a simple travel advisor application. Throughout the workshop, we will navigate through Bluemix, Github, and the source code of our application in order to demonstrate how apps can be created quickly and easily using the IBM Bluemix platform and the value of Watson Services and Cognitive capabilities through APIs.

So let’s get started. The first thing to do is to build out the shell of our application in Bluemix.

Creating a IBM Bluemix Account

  1. Go to https://ace.ng.bluemix.net/
  2. Create a Bluemix account if required.
  3. Log in with your IBM ID (the ID used to create your Bluemix account)


Note: The confirmation email from Bluemix mail take up to 1 hour.

Deploy this sample application in Bluemix

  1. Click the button below to fork the project into IBM DevOps Services and deploy your own instance of this application on IBM Bluemix.

Deploy to Bluemix

  1. From here you will be taken to a Bluemix page, where you will be prompted to name your app. A sample name is provided for you, but feel free to give your application any name you like (if the name is taken by another user you will be prompted to try another name).

deploy

Note: Use the default settings for Region / Organization / Space on the Bluemix landing page.

  1. Once you have named your application, click the deploy button to begin the deploy process to Bluemix. During this process, Bluemix will automatically build and deploy our starter application based on the Github repository that we accessed at the start of the lab.

  2. Once the application has finished deploying, you will see a "Success!" message. On the same screen, you will see buttons to "Edit Code" and "View App". Let's select the "View App" button to launch the app in it's current state.

deploy-success

  1. In the starter app, you are able to enter concepts in the bar provided and see what cities might be relevant. For this example, we entered "Snorkel" as a concept.

Right now, our app is interesting, but we can add more functionality into it to make it much more useful.

Modify the existing application

  1. It's time to edit our source code to build two more of the Watson services into the app. Back on the "Success!" page, click the button that says Edit Code.

  2. Within the repository, navigate to the app.js file and click on it to open the application source code.

  3. Locate the comment starting in line 89: // tradeoff analytics REST call - here.
    Copy the code below under that line:

app.post('/dilemmas', function(req, res, next) {
  tradeoffAnalytics.dilemmas(req.body, function(err, dilemmas) {
    if (err)
      return next(err);
    else
      return res.json(dilemmas);
  });
});

The code above will connect the app to the Tradeoff Analytics service.

app-js

  1. Click on File -> Save or press Crt+S.

app-js

We've added Tradeoff Analytics, but we need to update our application to reflect these changes.

Deploy

  1. The last step in order to complete our application is to deploy our changes to Bluemix. To do this, we need to push our new code to the application. In the code editor screen, switch to the Git view, the 2nd icon in the left navigation bar.

git

  1. Locate your change to app.js file. Check it (select it), add a commit message, and click Commit.

commit

  1. Click Sync to send your changes from this workspace to the main repository and trigger a deploy of your app.

sync

  1. Finally, Click on Build and Deploy to see the deploy process.

deploy-button

Note: While this may show as overly complicated, we show it here to illustrate you can have exactly the same source management practices you could have your local environment connected to a Git repository, in the Bluemix DevOps environment.

deploy-process

Test

To test out our application, go back to the "Success!" page and click on the "View App" button again.

deploy-success

You will see the finished application, which utilizes the Concept Insights and Tradeoff Analytics capabilities to provide a useful tool for users researching travel options. Let’s try testing the application out. In the "Text Input" section, we can search for places that you can go to snorkel. Enter "snorkel" into the text bar, and select "Snorkel" from the list of activities in the drop down menu.

snorkel

In the "Results" section, we see a list of possible locations that give us the opportunity for snorkeling. We can add additional criteria by clicking on the activities listed under any of the locations. Try clicking on one of these now, to narrow down our criteria. In our example, we clicked on "beaches” under "Rio de Janeiro".

Within the “Results” section, there is a button to "Compare with Tradeoff Analytics". Based on our current criteria, let’s select that now.

app-full

The app will navigate to the Tradeoff Analytics section, where you will be able to see how the different travel options compare to each other based on flight cost, population density, and distance.

In the grid that is visualized, our travel options are represented as lines that map to each of the values for cost, population density, and distance. By adjusting the sliders on the left-hand side, different options will be greyed out once they fall outside of the range set up by the slides. This allows users to quickly filter out options based on the parameters that matter to them when looking for a travel location

By clicking on one of the lines in the grid, we are able to see details about this option, and are able to select one of them as our decision.

For our example, we decided to make our decision between Rio de Janiero and Mar del Plata based on flight cost. Try moving the right slider on the flight cost to the left. Eventually you will see Mar del Plata disappear, as it has been filtered out based on our criteria.

Click on the line representing Rio and select "This is my decision". In the top right of the Tradeoff Analytics box you will see Rio loaded as our decision. Click the "Done" button, and then close the tradeoff analytics window with the "x" in the top right corner of the Tradeoff Anlaytics screen.

Congratulations

You have completed the Personalized Recommendations Lab! :bowtie: