Java Reference
In-Depth Information
31. transactionalAttrs[1] = psFactory.create("Product Name",
32. AttributeDataType.stringType, PhysicalAttributeRole.attributeName);
33. transactionalAttrs[2] = psFactory.create("Amount Range",
34. AttributeDataType.stringType, PhysicalAttributeRole.attributeValue);
35. pdsBuild.addAttributes(transactionalAttrs);
36.
37. AssociationSettings arSettings = arSettingsFactory.create();
38. arSettings.setMinConfidence(0.2);
39. arSettings.setMinSupport(0.2);
40. arSettings.setMaxRuleLength(10);
41. arSettings.setMaxNumberOfRules(100000);
42. dmeConn.saveObject( "ar_build_data", pdsBuild, replaceObject);
43. dmeConn.saveObject( "ar_build_settings", arSettings, replaceObject);
44. }
45.
46. //Create and execute tasks
47. public boolean run() throws JDMException {
48. //Create task object factories
49. btkFactory = (BuildTaskFactory)dmeConn.getFactory(
50. "javax.datamining.task.BuildTask");
51. //Run until completion when timeout is set to null
52. Long timeOut = null;
53. //Create and run build task
54. BuildTask btk = btkFactory.create( "ar_build_data",
55. "ar_build_settings", "ar_model" );
56. ExecutionStatus buildStatus = dmeConn.execute( btk, timeOut );
57. //If Build task is successful run test metrics task
58. if( ExecutionState.success.equals( buildStatus.getState() ) )
59. return true;
60. else
61. return false;
62. }
63.
64. //Retrieve built model and test metrics
65. public void output() throws JDMException {
66. //Retrieve regression model
67. AssociationModel arModel =
68. (AssociationModel)dmeConn.retrieveObject("ar_model",NamedObject.model);
69. //Create a rules filter object that filters the rules that have specified range of
70. //support and confidence. In addition filter can specify the sort order of the
71. //rules.
72. RulesFilterFactory rulesFilterFactory = dmeConn.getFactory(
73. "javax.datamining.association.RulesFilter");
74. RulesFilter filterByConfidenceSupport = rulesFilterFactory.create();
75. filterByConfidenceSupport.setRange(RuleProperty.confidence, 0.5, 1.0);
76. filterByConfidenceSupport.setRange(RuleProperty.support, 0.5, 1.0);
77. filterByConfidenceSupport.setOrderingCondition(
78. new RuleProperty[] { RuleProperty.confidence, RuleProperty.support },
79. new SortOrder[] { SortOrder.descending, SortOrder.descending } );
80. //Create another filter that filters by items in antecedent and consequent
 
Search WWH ::




Custom Search