Task 4: Creating a data model
You add a data model to enumerate the temperatures cold, warm, and hot. When you run the model, it displays a greeting and advice for a cold day.
Step 1: Creating a data model and enumerating a type
You create a data model to define custom data types for your service. Built-in data types,
including string and integer, are predefined by default in Decision Intelligence. However, organizations often need custom
data types that match their operations. For example, a car rental company might need special types
such as car, fleet and rental price. These types
are defined in a data model, and can be used in multiple artifacts in a decision service (see Modeling data).
- Click My Service in the navigation breadcrumbs to return to your decision service.
- Go to the Data tab.
- Click Create + to create a data model.
- Enter
Datain the Name field, and click Create.The data model editor opens.
- In the data model editor, click Add a data type or a function
next to Data model, and select Enumeration type.
- Change the name of the new enumeration type from
new enumtotemperature.Take a moment explore the editor. The first part displays the language, the documentation, and the different verbalizations of the vocabulary elements. You can collapse this part by clicking the arrow to the right of the type name.
- In the Values section, click the Add + button twice to add two more values.
- Change the names of the values to
cold,warm, andhot.Your changes are automatically saved. These values now define the enumeration type temperature.
Step 2: Adding a composite data type
- In the data model editor, click Add
next to Data model, and select Composite type.
- Change the name of the new composite type from
new typetoweather. - In the Attributes section, click the Add + button twice to create two attributes.
- Enter the following names and types for the attributes:
Name Type temperaturetemperature rain forecastThe
temperatureand therain forecastnow define theweatherdata type.
Step 3: Declaring a dependency
- Open the Navigation history
in the upper right toolbar, and click My Model to open it.
- Open the Dependencies tab.
- Click the Add + button to declare a new dependency.
- Select Data in the table and click Add. Note: If the table contains multiple Data entries, select the entry where the Version is set to current.
The custom data types are now ready to be used in the decision model.
Step 4: Changing the decision logic
- Return to the Modeling tab to work on your decision model.
- Change the name of the
Rain forecastnode toWeather, and change its output type to weather.Because these changes are automatically reflected in the dependent node, the Weather advice node shows an error. You resolve the error by updating the weather decision table to use the new data type.
- In the Weather advice node, open .
- Double-click the header of the Rain forecast column, and change the name
to
Rain forecast %. - Right-click the header again, and select Define column. Enter the
following condition in the rule editor, and then click OK:
the rain forecast of 'Weather' is at least <min> and less than <max>The table no longer displays an error.
- Right-click the header again, and select .
- Change the name of the new column to
Temperature. - Right-click the header of the new column, and select Define column. Enter
the following condition, and then click OK:
the temperature of Weather is <a temperature> - Double-click the first cell in the Temperature column, and select cold from the menu.
- Double-click the first cell in the Weather advice column, and enter a new
message:
Cold day. Take a coat. - Hover over the warning icon
. It displays the following message:
Lines 1 to 1 have gaps - Missing values: hot, warm
You defined three values for the enumeration type temperature. One value is declared in the table, but the editor warns you that two values are undeclared:
hotandwarm. Because the model still runs, the editor shows a warning and not an error.You decide to ignore the warning for now, and disable the gap checking. You can return to the table to make more changes after you deploy the decision service in task 6.
- Right-click the Temperature column header, and deselect Check gap to hide the warning. The gaps do not prevent the operation of the model.
- Click Back to the diagram to close the editor.
The table now provides advice for a cold day with rain forecast less than 20%.
Step 5: Running the model
- Go to the Run tab.
- Add the following test data:
- name: Jamie
- rainForecast: 0
- temperature: cold
- Click Run. You get the following message:
"Hello Jamie! Cold day. Take a coat."
- Change the test data:
- name: Robin
- rainForecast: 90
- temperature: warm
- Click Run. You get the following message:
"Hello Robin! Rainy day. Take an umbrella."
- Delete the test data for the next task.