Java Reference
In-Depth Information
50. "segment_id");
51. //Carry forward customer id column
52. Map sourceDestMap = new HashMap();
53. sourceDestMap.put("cust_id","Customer id");
54. clusApplySettings.setSourceDestinationMap(sourceDestMap);
55. dmeConn.saveObject( "segmentApplySettings", clusApplySettings, true);
56. }
57.
58. //Create and execute tasks
59. public boolean run() throws JDMException {
60. //Create task object factories
61. btkFactory = (BuildTaskFactory)dmeConn.getFactory(
62. "javax.datamining.task.BuildTask");
63. atkFactory = (DataSetApplyTaskFactory)dmeConn.getFactory(
64. "javax.datamining.task.apply.DataSetApplyTask");
65.
66. //Run until completion when timeout is set to null
67. Long timeOut = null;
68. //Create and run build task
69. BuildTask btk = btkFactory.create("segment_build_data",
70. "segment_build_settings", "segment_model");
71. ExecutionStatus buildStatus = dmeConn.execute(btk, timeOut);
72. //If Build task is successful run apply task
73. if(ExecutionState.success.equals( buildStatus.getState())) {
74. DataSetApplyTask applyTask =
75. atkFactory.create( "segment_apply_data", "segment_model",
76. "segment_apply_settings", "segment_apply_output");
77. ExecutionStatus applyStatus = dmeConn.execute(applyTask, timeOut);
78. //If the apply task on test data is successful then run test metrics task
79. if( ExecutionState.success.equals(applyStatus.getState()))
80. return true;
81. else
82. return false;
83. } else {
84. System.out.println("Failed due to: " + testApplyStatus.getDescription());
85. return false;
86. }}
87. else {
88. System.out.println("Failed due to: " + buildStatus.getDescription());
89. return false;
90. }}
91.
92. //Retrieve built model and test metrics
93. public void output() throws JDMException {
94. //Retrieve regression model
95. ClusteringModel clusModel = (ClusteringModel)dmeConn.retrieveObject(
96. "segment_model", NamedObject.model );
97. //Get clusters
98. Collection clusters = clusModel.getLeafClusters();
99. Iteraor clusterIterator = clusters.iterator();
100. while(clusterIterator.hasNext()) {
 
Search WWH ::




Custom Search