This a customized version of the Node.js sample app that is available with the Watson Machine Learning Service on IBM Bluemix. This version of the app is to be used with the Data Science Experience Service to test a predictive model developed in the lab.
See the original app for a walkthrough of the source code.
Lab - Create and deploy a scoring model to predict heart failure w/Bluemix and the IBM Data Science Experience
© Copyright IBM Corporation 2017
IBM, the IBM logo and ibm.com are trademarks of International Business Machines Corp., registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at "Copyright and trademark information" at www.ibm.com/legal/copytrade.shtml.
This document is current as of the initial date of publication and may be changed by IBM at any time.
The information contained in these materials is provided for informational purposes only, and is provided AS IS without warranty of any kind, express or implied. IBM shall not be responsible for any damages arising out of the use of, or otherwise related to, these materials. Nothing contained in these materials is intended to, nor shall have the effect of, creating any warranties or representations from IBM or its suppliers or licensors, or altering the terms and conditions of the applicable license agreement governing the use of IBM software. References in these materials to IBM products, programs, or services do not imply that they will be available in all countries in which IBM operates. This information is based on current IBM product plans and strategy, which are subject to change by IBM without notice. Product release dates and/or capabilities referenced in these materials may change at any time at IBM's sole discretion based on market opportunities or other factors, and are not intended to be a commitment to future product or feature availability in any way.
In this lab you will build a predictive model to predict if certain patients being monitored for irregular heart activity are at risk for heart failure.
The predictive model is built in the IBM Data Science Experience with Apache Spark and is then deployed to the Watson Machine Learning Service in Bluemix where it is used by an application.
- Bluemix supported web browser
- An IBM Bluemix Account
- The Bluemix bx (CLI). Note: The cygwin shell is not supported for the bx CLI, on Windows. Instead, use a command prompt, powershell, or git bash shell
The IBM Data Science Experience is an interactive, collaborative, cloud-based environment where data scientists can use multiple tools to activate their insights. In this part of the lab you will sign up for a 30 day trial of the IBM Data Science Experience.
-
In a web browser navigate to https://datascience.ibm.com
-
Click on Sign Up at the top right.
- Click on Sign in with your IBM id and enter your Bluemix credentials.
-
- Follow the prompts to complete the sign up for the Data Science Experience. Two Bluemix services will be created for you (Object Storage and Apache Spark) and you should be presented with the Data Science Experience dashboard.
In this part of the lab you'll deploy the application that you will use later to test the predictive model that you create.
-
Log in into Bluemix with your credentials by clicking on the Log in link at the top right.
-
Click on Deploy
- A Toolchain and Delivery Pipeline will be created for you to pull the app out of Github and deploy it in to Bluemix. Click on the Delivery Pipeline tile to see the status of the deployment.
- Wait for the Deploy Stage to complete successfully
In this part of the lab, you'll create an instance of the Watson Machine Learning service and bind it to the app that you created in part 2.
-
In your browser go to the Bluemix Dashboard. Click Catalog
-
In the navigation menu at the left, select Data & Analytics (under Services) and then select IBM Watson Machine Learning
- On the left select your app from part 2 in the drop down labeled Connect to:
-
Click Create
-
Click Restage when you’re prompted to restage your app
- Go back to the Bluemix dashboard and wait until the app shows that it is running again
Step 4: Create a project in the IBM Data Science Experience and bind it to your Watson Machine Learning service instance
In this part of the lab you will create a new project in the IBM Data Science Experience and bind it to your instance of the Watson Machine Learning service
-
In a new browser tab go to the https://datascience.ibm.com
-
Click on Sign in at the top of the page
-
Click on Quick Start Guide and then Create New Project
-
Enter Watson ML Integeration as the project name and click Create
-
On the right click on Browse to upload the data file you’ll use to create a predictive model.
-
Select the file patientdataV6.csv and click Open.
-
The file should now appear in the Data Assets section
- Click on Settings for the project
- Click on add associated service and select Machine Learning
- Choose your existing Eatson Machine Learning instance and click on Select
- Click on your browser’s Back button and verify that the Watson Machine Learning service is now listed as one of your Associated Services
- Leave the browser tab open for later.
In this part of the lab you’ll save the credentials for your Watson Machine Learning instance so you can use it later in your code
-
In a different browser tab go to http://bluemix.net and log in to the Dashboard
-
- Double click on your Watson Machine Learning instance under All Services
- Click on Service credentials and then on View credentials to see the credentials
- Save the username and password to a text file on your machine as you’ll need this information in your code later.
In this part of the lab you’ll create a Jupyter notebook and import the code to create a predictive model
- In the Data Science Experience browser tab click on Overview and then click on add notebooks
-
Click on From File and name the notebook Apache Spark integration with Watson ML
-
Under Notebook File select the file demo1.ipynb
-
Click Create Notebook to create the new notebook
-
Leave your browser tab open for the next part
In this part of the lab you will run the notebook code to create a predictive model and save it in the Watson Machine Learning Service.
- Place your cursor in the first code block in the notebook.
- Click on the Find and Add data icon (see step 1 in diagram below) and then select Insert to code under the file patientdataV6.csv (see step 2 in diagram below). Finally select Insert Credentials (see step 3 in diagram below)
- Your Object Storage credentials should now be in the cell.
- Click on the Run icon to run the code in the cell
-
Move your cursor to each code cell and run the code in it. Read the comments for each cell to understand what the code is doing. Important when the code in a cell is still running, the label to the left changes to In [*]: . Do not continue to the next cell until the code is finished running.
-
When you get to the cell that says Stop here !!!! insert the username and password that you saved from your Watson Machine Learning instance into the code before running it.
- Continue running each cell until you finish the entire notebook.
In this part of the lab you’ll deploy the model you save by running the Python notebook as a scoring service in Watson Machine Learning
-
In a different browser tab go to http://bluemix.net and log in to the Dashboard
-
Double click on the entry for your Watson Machine Learning service under Services
-
Click Manage and then click on the Launch Dashboard button in the Watson Machine Learning tile
- Your saved model should appear. Under Actions select Create Deployment
-
Name the deployment Heart Failure Prediction Model Deployment and click Save
-
Your model should now be deployed and visible as a Deployment
In this part of the lab you’ll test the deployed model with the app that you deployed earlier.
-
In a different browser tab go to http://bluemix.net and log in to the Dashboard
-
Click on the URL for the app that you deployed earlier that tests the deployed model
-
When the application appears click on Score now to test the scoring model with the default values.
-
Verify that the model predicts that there is a risk of heart failure for the patient with these medical characteristics
- Click Close. Run the app again with the following parameters
- Verify that the model predicts that there is not a risk of heart failure for the patient with these medical characteristics
Congratulations, you successfully created a predictive model in Apache Spark and deployed and tested it using the Watson Machine Learning Service in Bluemix
Congratulations, you successfully created a predictive model in Apache Spark and deployed and tested it using the Watson Machine Learning Service in Bluemix