In this code pattern, we will create an application using IBM Decision Optimization, Watson Machine Learning, HERE Technologies, and Plotly Dash. Using data provided by HERE Geocoding and Search API, a Decision Optimization model deployed in Watson Machine Learning will find the optimal locations to establish temporary emergency sites.
The model created is a basic Decision Optimization model with the main purpose of demonstrating the integration of Decision Optimization with HERE Technologies. This model can and should be improved upon by the reader to include better constraints that can provide a more optimal solution.
When the reader has completed this pattern, they will understand how to:
- Create a Decision Optimization model in Watson Studio
- Deploy a Decision Optimization model in Watson Machine Learning
- Use HERE's Geocoding and Search API to pinpoint geo-coordinates and get Places data
- Run a Plotly Dash application with Decision Optimization and HERE Technologies integration to identify locations for temporary emergency sites
- Decision Optimization model is built and deployed to Watson Machine Learning
- The user interacts with the application
- User inputs a location to request a list of Places in the vicinity
- The input is sent to HERE Location services and returned Places are displayed in the UI
- User triggers a request to find optimal sites from the list of Places
- The Places data is sent to Watson Machine Learning and returned sites are displayed in the UI
- IBM Decision Optimization: IBM Decision Optimization represents a family of optimization software that delivers prescriptive analytics capabilities to enable organizations to make better decisions and deliver improved business outcomes.
- Watson Studio: Analyze data using RStudio, Jupyter, and Python in a configured, collaborative environment that includes IBM value-adds, such as managed Spark.
- Watson Machine Learning: IBM Watson Machine Learning makes it easy and cost-effective to deploy AI and machine learning assets in public, private, hybrid or multicloud environments.
- HERE Location Services: Solve complex location problems from geofencing to custom routing with HERE Location services.
- Plotly Dash: The Dash platform empowers Data Science teams to focus on the data and models, while producing and sharing enterprise-ready analytic apps that sit on top of Python and R models.
- Jupyter Notebooks: An open-source web application that allows you to create and share documents that contain live code, equations, visualizations, and explanatory text.
- Clone the repo
- Generate an API Key from the HERE Developer Portal
- Provision a Watson Machine Learning service
- Build and deploy the Decision Optimization model
- Deploy the application
- Use the application
Clone the do-here-demo
repository locally. In a terminal, run:
git clone https://github.com/IBM/do-here-demo
The application uses HERE Location Services for maps and searching.
To access these services, you'll need an API key. Follow the instructions outlined in the HERE Developer Portal to generate an API key.
- If you do not have an IBM Cloud account, register for a free trial account.
- Log into IBM Cloud
- Create a Watson Machine Learning service instance
- Look up your Watson Machine Learning service instance credentials (required in the Deploy the application step below)
- Log into IBM Watson Studio
- Create a new Project
- Import the notebook
do_with_wml.ipynb
into the new ProjectNote The URL for the notebook is
https://raw.githubusercontent.com/IBM/do-here-demo/master/notebook/do_with_wml.ipynb
- Run the imported notebook to build the Decision Optimization model and deploy it into Watson Machine Learning
Note: You will need to update one of the notebook cells to include your Watson Machine Learning instance credentials. Follow these steps to find the service credentials.
- Make note of the model deployment GUID
If you do not have the IBM Cloud CLI installed, download and install the IBM Cloud CLI before continuing.
From a command line:
-
Go into the
dash-app
directory of the cloned repositorycd <path_to_cloned_repo>/dash-app
-
Make a copy of the
.env.example
file in thedash-app
directory in the GitHub repository, and name it.env
.cp .env.example .env
-
Edit the newly created
.env
file and update the following variables accordingly:HERE_API_KEY
- REST API key for the HERE Location servicesWML_API_KEY
- API key for the Watson Machine Learning serviceWML_INSTANCE_ID
- Instance ID for the Watson Machine Learning serviceWML_URL
- URL for the Watson Machine Learning serviceWML_DEPLOYMENT_UID
- UID for the deployment Decision Optimization model
-
Log in to your IBM Cloud account using the IBM Cloud CLI:
ibmcloud login
-
Target a Cloud Foundry org and space
ibmcloud target --cf
-
Push the app to IBM Cloud
ibmcloud app push
-
Access the server at the URL displayed in the console after the application has been pushed to IBM Cloud (for example, https://some-random-route.bluemix.net).
The web app presents a dashboard containing a map view and some form fields. Change the default form values and click Search places to view Places on the map based on the form values. Click on the Run model button to pass the current Places data to the Decision Optimization model. The map gets updated to show the (top 3) results returned by the model.
The app will display some statistics from the model run as well as the following markers on the map:
green
: location of the Address.red
: location of nearby hospitalsblue
: location of places returned by HERE search or model results
- IBM Decision Optimization
- Watson Studio
- Watson Machine Learning
- DOcplex examples
- Documentation for IBM Decision Optimization CPLEX Modeling for Python
- Decision Optimization and Machine learning on IBM Watson Studio and Watson machine learning
- HERE.com API Key
- HERE Maps
- HERE Geocoding and Search
- Integrate interactive maps and location features into your application