Applying sequence rule models

You can apply sequence rule models that were built based on transaction tables by using the ApplySeqRuleModel procedure. After you have built a sequence rule model, you might want to apply it to new data records to determine the item sets in the rule head that can be inferred. If the new data represents the current contents of market baskets, you can consider the inferred items as the items that your customers might be interested in. This means that you can recommend these items to your customers.

You can also apply sequence rule models to the input table that was used to build the model. By applying sequence rule models to input tables, you can determine the sequences that support a sequence rule. Sequences that support a sequence rule contain the item sets of a sequence rule in the right order.

You can apply sequence rule models to input tables by using the ApplySeqRuleModel procedure.

Syntax

IDMMX.ApplySeqRuleModel(<modelName>,
                        <inputTable>,
                        <outputView>,
                        <ruleIdColumn>,
                        <headColumn>,
                        <headNameColumn>,
                        <supportColumn>,
                        <confidenceColumn>,
                        <liftColumn>,
                        <matchHeadColumn>,
                        <matchBodyColumn>)

Input parameters

With the ApplySeqRuleModel procedure, you must specify the following parameters:
<modelName>
The name of the model that you want to apply to a table or a view.

The model is stored in the IDMMX.RuleModels table.

This parameter is of type VARCHAR. Its size is 240.

<input table>
The name of the input table or the input view.

The ApplyRuleModel procedure applies the sequence rule model to the data in this table. The input table must contain the following columns:

  • Sequence column
  • Group column
  • Item columns

These columns are required to build the model.

This parameter is of type VARCHAR. Its size is 240.

<outputView>
The name of the output view.
The output view contains the sequence column and the following additional columns. These columns are only included in the output view if their names are not NULL or an empty string.
  • Rule ID column
  • Head column
  • Head name column
  • Support column
  • Confidence column
  • Lift column
  • Match head column
  • Match body column

This parameter is of type VARCHAR. Its size is 240.

<ruleIdColumn>
The name of the column that contains the ID of the matching sequence rule.

This parameter is of type VARCHAR. Its size is 128.

<headColumn>
The name of the column that contains the rule head item set of the matching sequence rule.

For each rule head item set of a sequence rule, one record is returned.

This parameter is of type VARCHAR. Its size is 128.

<headNameColumn>
The name of the column that contains the names of the items in the rule head item set of the matching sequence rule.

This parameter is of type VARCHAR. Its size is 128.

<supportColumn>
The name of the column that contains the support value of the matching sequence rule.

This parameter is of type VARCHAR. Its size is 128.

<confidenceColumn>
The name of the column that contains the confidence value of the matching sequence rule.

This parameter is of type VARCHAR. Its size is 128.

<liftColumn>
The name of the column that contains the lift value of the matching sequence rule.

This parameter is of type VARCHAR. Its size is 128.

<matchHeadColumn>
The name of the column that contains the match head value.

If the head item set is included in the sequence, this column contains the value 1. If the head item set is not included in the sequence, this column contains the value 0.

This parameter is of type VARCHAR. Its size is 128.

<matchBodyColumn>
The name of the column that contains the match body value.

This value is equal to the number of item sets that are included in the rule body because only the sequence rules are returned whose body item sets are included in the sequence in the right order.

This parameter is of type VARCHAR. Its size is 128.

Example

To apply the model BANK.PRODUCT_SEQ_RULES to the table BANK.CUSTOMERS2, use the following command:
db2 "call IDMMX.ApplySeqRuleModel('BANK.PRODUCT_SEQ_RULES',
                                  'BANK.CUSTOMER_PRODUCTS2',
                                  'BANK.APPLY_RULES_VIEW',
                                  'RULEID',
                                  'HEAD',
                                  'HEADNAME',
                                  'SUPPORT',
                                  'CONFIDENCE',
                                  'LIFT',
                                  'MATCHHEAD',
                                  'MATCHBODY')"


Feedback | Information roadmap