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).

  1. Click My Service in the navigation breadcrumbs to return to your decision service.
  2. Go to the Data tab.
  3. Click Create + to create a data model.
  4. Enter Data in the Name field, and click Create.

    The data model editor opens.

  5. In the data model editor, click Add a data type or a function Add button next to Data model, and select Enumeration type.
  6. Change the name of the new enumeration type from new enum to temperature.

    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.

  7. In the Values section, click the Add + button twice to add two more values.
  8. Change the names of the values to cold, warm, and hot.

    Your changes are automatically saved. These values now define the enumeration type temperature.

Step 2: Adding a composite data type

  1. In the data model editor, click Add Add button next to Data model, and select Composite type.
  2. Change the name of the new composite type from new type to weather.
  3. In the Attributes section, click the Add + button twice to create two attributes.
  4. Enter the following names and types for the attributes:
    Name Type
    temperature temperature
    rain forecast integer > int (32 bits)

    The temperature and the rain forecast now define the weather data type.

Step 3: Declaring a dependency

  1. Open the Navigation history Navigation history icon in the upper right toolbar, and click My Model to open it.
  2. Open the Dependencies tab.
  3. Click the Add + button to declare a new dependency.
  4. 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

  1. Return to the Modeling tab to work on your decision model.
  2. Change the name of the Rain forecast node to Weather, 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.

  3. In the Weather advice node, open Logic > weather table.
  4. Double-click the header of the Rain forecast column, and change the name to Rain forecast %.
  5. 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.

  6. Right-click the header again, and select Insert column > Condition after.
  7. Change the name of the new column to Temperature.
  8. 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>
  9. Double-click the first cell in the Temperature column, and select cold from the menu.
  10. Double-click the first cell in the Weather advice column, and enter a new message:
    Cold day. Take a coat.
  11. Hover over the warning icon 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: hot and warm. 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.

  12. Right-click the Temperature column header, and deselect Check gap to hide the warning. The gaps do not prevent the operation of the model.
  13. 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

  1. Go to the Run tab.
  2. Add the following test data:
    • name: Jamie
    • rainForecast: 0
    • temperature: cold
  3. Click Run. You get the following message:
    "Hello Jamie! Cold day. Take a coat."
  4. Change the test data:
    • name: Robin
    • rainForecast: 90
    • temperature: warm
  5. Click Run. You get the following message:
    "Hello Robin! Rainy day. Take an umbrella."
  6. Delete the test data for the next task.