Java Reference
In-Depth Information
81. RulesFilter filterByItems = filterByItems.create();
82. filterByItems.setItems(new Object[] { "Savings Account" },
83. RuleComponentOption.antecedent, true );
84. filterByItems.setItems(new Object[] { "Certificate Account" },
85. RuleComponentOption.consequent, true );
86. //Get filtered rules
87. Collection rulesByConfidenceSupport=arModel.getRules(filterByConfidence Support);
88. Collection rulesByItems = arModel.getRules(filterByItems);
89. //Iterate and display rules by items
90. Iterator rulesByItemsIterator = rulesByItems.iterator();
91. while(rulesByItemsIterator.hasNext()) {
92. AssociationRule arRule = (AssociationRule)rulesByItemsIterator.next();
93. ItemSet arRule.getItemSet();
94. ItemSet antecedentItemSet = arRule.getAntecedent();
95. ItemSet consequentItemSet = arRule.getConsequent();
96. Object[] antecedentItems = antecedentItemSet.getItems();
97. Object[] consequentItems = consequentItemSet.getItems();
98. //Display rule contents
99. System.out.print("\n Rule-" + arRule.getRuleIdentifier() + ": IF");
100. for(int i=0; i < antecedentItems.length; i++)
101. System.out.print(antecedentItems[i].toString() + " ");
102. System.out.print(" THEN ");
103. for(int j=0; j < consequentItems.length; j++)
104. System.out.print(consequentItems[j].toString() + " ");
105. }} }
9.8
Using Clustering Interfaces
The javax.datamining.clustering package contains clustering function
interfaces, such as ClusteringSettings , ClusteringModel , Cluster , and
ClusteringApplySettings . Table 9-20 shows the clustering-related inter-
face methods. ClusteringSettings provides various set methods for
users to select the aggregation function, attribute comparison func-
tion, maximum number of model clusters, maximum and minimum
size of clusters allowed, etc. As a descriptive model, a clustering
model allows users to examine its contents. The ClusteringModel
interface provides methods to retrieve clusters, rules, and if it is a
hierarchical cluster model, the hierarchical structure. Table 9-20
shows the list of methods in ClusteringModel .
The Cluster interface provides methods to retrieve cluster-specific
details such as cluster id, name, attribute statistics, and number of
cases that substantiate the cluster. For hierarchical cluster models,
users can retrieve the cluster children, parent, and ancestors. Similar
to supervised models, clustering models can be applied to assign
apply data cases to the most closely matching cluster. The Clustering
ApplySettings object provides several map methods, as shown in
 
Search WWH ::




Custom Search