Java Reference
In-Depth Information
to 104 show retrieving the model and its contents using different
filters and displaying the rules. The association.RulesFilter interface
provides multiple filtering and sorting capabilities for selecting sub-
sets of model rules. Typically, association models contain a large
number of rules (tens or hundreds of thousands). Consequently,
applications need a powerful and flexible filtering mechanism to
obtain the rules of interest. Lines 72 to 79 show the creation of the
rules filter to obtain rules with support and confidence greater than
0.5 and to order those rules in descending order of the confidence
and support. Lines 81 to 85 show another type of rules filter used to
obtain rules with antecedent item “savings account” and consequent
item “certificate account.” Lines 87 and 88 show rules retrieval that
satisfies these two filtering criteria. Lines 87 to 105 show how to
display the retrieved rules; this highlights several AssociationRule
interface methods.
Listing 9-16
Build Association model to discover product associations
1. public class CrossSellProducts {
2. //Data members
3. . . .
4. static AssociationSettingsFactory arSettingsFactory = null;
5. . . .
6. //Main method
7. public static void main(String args[]) throws Exception {
8. try {
9. //Create DME connection as shown in Listing 9.1 or 9.2
10. // . . .
11. input(); //Create input objects
12. if( run() ) //Execute model build task
13. output(); //Retrieve the model
14. } catch(Exception anyFailures) { anyFailures.printStackTrace();
15. } finally { if(dmeConn != null) dmeConn.close(); //Close connection
16. }}
17.
18. //Create and save input objects
19. public static void input() throws JDMException {
20. //Create Input object factories
21. . . .
22. arSettingsFactory = (AssociationSettingsFactory)dmeConn.getFactory(
23. "javax.datamining.association.AssociationSettings");
24.
25. boolean replaceObject = true;
26. //Input objects for building appraisal_model using appraisal_build_data dataset
27. PhysicalDataSet pdsBuild = pdsFactory.create( "product_transactions", false );
28. PhysicalAttribute[] transactionalAttrs = new PhysicalAttribute[3];
29. transactionalAttrs[0] = psFactory.create("CustomerId",
30. AttributeDataType.integerType, PhysicalAttributeRole.caseId);
Search WWH ::




Custom Search