Examples for creating sequential patterns

This example shows how to detect significant and useful sequential patterns on the RETAILS sample data set.

The RETAILS table comes from the retail table and is extended by an SID column that groups transactions into sequences of transactions. The minimum support is set to 3% of the total number of input sequences. The minimum confidence is set to 0.5.

The following call shows how to discover sequential patterns and rules.

CALL IDAX.SEQRULES('model=retails_seq, intable=retails, sid=sid, tid=tid, item=item, minsupport=0.03, minconf=0.5');

To inspect the built model, use the following PRINT_MODEL stored procedure. You can print the patterns or the rules. Additionally, you can filter out patterns of rules according to their support, lift, confidence, length, time, or items that they contain or that they do not contain. You can sort the result and truncate it to a specified number of rows

CALL IDAX.PRINT_MODEL('model=retails_seq, type=patterns, minlen=3, itemsin=32;41, maxlift=2, limit=20');

If some of the rules or patterns are not useful to you, you can prune the sequential patterns model by using almost the same parameters that you use for printing. You can first print the rules by using the filter parameters; and when the resulting output suits your needs, you can prune the model to exactly those rules and patterns.

For example, the following call prunes the model, that is, restricts its content, to exactly the rules that were used in the first call of PRINT_MODEL.

CALL IDAX.PRUNE_SEQRULES('model=retails_seq, minlen=3, itemsin=32;41, maxlift=2');

The patterns and rules that are pruned are not deleted from the model, but marked as inactive. The following call activates these patterns and rules again.

CALL IDAX.PRUNE_SEQRULES('model=retails_seq, reset=true');

Finally, you can use the model to detect or predict the purchase behavior of other customers. Only non-pruned patterns and non-pruned rules are considered. When you apply the model on new input sequences of transactions, you can detect the patterns in these input sequences. Moreover, you can detect rules the body of which but not the head of which is in the input sequence. By using these rules, you can predict that this customer probably buys the items that are contained in the head of the rule in the future.

The following call predicts the rules that apply to the same input table. The call delivers only the most confident rule per input sequence.

CALL IDAX.PREDICT_SEQRULES('model=retails_seq, intable=retails, outtable=retails_out, type=rules, sort=confidence, limit=1');