Controlling the number of rules

You can control the number of rules that are to be included in a sequence rule model or an association rules model by using a rule filter.

To create a DM_RuleBldTask value with a rule filter and to start a training run for sequence rules, run the sample script retailRuleFilter.db2 by using the following command:
db2 -stf retailRuleFilter.db2
The following excerpt from the sample script retailRuleFilter.db2 contains an INSERT statement. This INSERT statement builds a value of DM_RULEBLDTASK and inserts this value and the ID RetailRulesTaskWithRuleFilter into the IDMMX.RULETASKS table. For an explanation of the constraints, see the comments that are included in the script.
INSERT INTO IDMMX."RULETASKS" ("ID", "DESCRIPTION", "BUSINESS_NAME", "TASK")
WITH  "MYDATA" ("MYMININGDATA") AS (
        VALUES(IDMMX.DM_MiningData()..DM_defMiningData('RETAIL')
        ))
SELECT 'RetailRulesTaskWithRuleFilter',
       'Task created by Intelligent Miner sample retailRuleFilter.db2',
       'Determine buying behaviour with limited rules',
IDMMX.DM_RuleBldTask()..
DM_defRuleBldTask(
   "MYMININGDATA",
   IDMMX.DM_RuleSettings()
     ..DM_useRuleDataSpec(MyMiningData..DM_genDataSpec()
        ..DM_addNmp('DescriptionForITEMID','RETAIL_NAMES','ITEMID',
                    'DESCRIPTION')
        ..DM_setFldNmp('ITEMID','DescriptionForITEMID'))
     ..DM_setItemFld('ITEMID')
     ..DM_setGroup('TRANSDATE')
     ..DM_setSequence('CUSTOMER_ID')
     ..DM_setRuleFilter( IDMMX.DM_RuleFilter()
-- sequence rules' support   (<--constraintID=1) must be in (13%...100%) 
       ..DM_addRangeConstr(1,13,100,1)
-- sequence rules' confidence(<--constraintID=2) must be in (50%...100%) 
       ..DM_addRangeConstr(2,50,100,1)
-- sequence rules' lift      (<--constraintID=3) must not be in )0.5...2.0(
       ..DM_addRangeConstr(3,0.5,2.0,-1)
-- sequence rules' support*confidence (<-- ID=4) must be in (1000%%...10000%%) 
--       ..DM_addRangeConstr(4,1000,10000,1)
-- sequence rules' nbOfItems (<--constraintID=5) must be between 2 and 4 (incl.)
       ..DM_addRangeConstr(5,2,4,1)
-- sequence rules' nbOfItemsets (<--constr.ID=6) must be between 2 and 3 (incl.)
       ..DM_addRangeConstr(6,2,3,1)
-- sequence rules must have a total elapsed time between 1 and 10 time units
       ..DM_addRangeConstr(7,1,10,1)
-- each time step between adjacent itemsets must not be 2 time units.
       ..DM_addRangeConstr(8,2,2,-1)
-- the head of each sequence rule must not contain the item '129' (=Cream)
       ..DM_setItemConstr('129',-2,CAST(NULL AS INTEGER))
-- the body of each sequence rule must contain the item '108' (=Cider)
       ..DM_setItemConstr('108',1,CAST(NULL AS INTEGER))
-- no sequence rule may contain the item '142' (=Lemonade)
       ..DM_setItemConstr('142',-3,CAST(NULL AS INTEGER))
     )
   )  
FROM "MYDATA";
In the example above, the following methods are used to restrict the rules to be found:


Feedback | Information roadmap