Model development with Databases

AlainChabrier
3 min readOct 16, 2019

--

Decision Optimization model development process requires data so that different model formulations can be tested. While some people always prefer to work with local files snapshots (e.g. CSV files), it is sometimes very useful to directly connect the model development tools to databases. This is now very easy to do in Decision Optimization for Watson Studio.

Following these simple steps, you will be able, within a few minutes, to test the data connection into the Decision Optimization in Watson Studio model builder Beta.

The three steps are:

  1. Create a DB with some data
  2. Connect data from a Watson Studio project
  3. Create a DO model and use this data

1. Create a DB on Cloud Trial instance

One easy way to test the DB connection from the model builder is to use some trial DB2 on cloud instance. You can do this here: https://cloud.ibm.com/catalog/services/db2.

After you create the free trial instance, you should go into the instance and create some credentials that you will need to connect from Watson Studio.

My DB instance and credentials

Note than from IBM Cloud, you can also access a console to easily create and explore your database. You can even drop data file to create tables, so just drop your preferred CSV files.

Exploring the DB content using the web console.

2. Create Watson Studio connections and connected data

In a Watson Studio project, the first thing to do is to create a new connection.

Creating a connection in Watson Studio

Among the possible types of connection, choose DB2 on cloud.

All available connections type from Watson Studio

in the last screen, you enter your credentials copied previously:

Setup connection using the credentials

Once the connection is created, you can create as many connected data on different tables using this connection.

In the project create new connected data:

Setup connected data

In the next screen you can choose your connection and explore to select the table you want to connect.

3. Use connected data in the model builder

The last step if to create an optimization model using the model builder. This post provides some quick start hints..

In the data preparation step, the connected data will appear as candidates to be imported.

Import all types of data from the project data assets

As you import connected data into a scenario, a snapshot of the DB table is taken. That ensures the data is not modified under the hood. If you want to take another snapshot, just re-import this connected data and select replacement option.

Information panel shows data linage

All model builder functionality is compatible with connected data, you can create different scenarios, create visualizations, with OPL, Python or the Modeling Assistant.

Deployment

When models are deployed to be integrated into production application, you can still use connected data. For that, use reference data instead of inline data in the job creation payload (or in the python configuration). The structure is described in this documentation.

alain.chabrier@ibm.com

https://www.linkedin.com/in/alain-chabrier-5430656/

https://twitter.com/AlainChabrier

--

--

AlainChabrier

Former Decision Optimization Senior Technical Staff Member at IBM Opinions are my own and I do not work for any company anymore.