Java Reference
In-Depth Information
task. Lines 31 to 35 show how to get the confusion matrix object from
the test metrics and retrieve model prediction accuracy , prediction error ,
and the number of predictions for the specified actual and predicted
target values. Using these data, applications can construct a visual
representation of the confusion matrix as was shown in Table 7-6.
Lines 37 to 44 show how to get the lift object from the test metrics and
retrieve cumulative lift and gain values that can be used to plot
cumulative lift and gain charts as was shown in Figure 7-6. Lines 47
to 57 show how to get the ROC object from the test metrics and
retrieve true and false positive rates at various threshold points to
plot the ROC graph as was shown in Figure 7-7.
Listing 9-11
Classification test metrics computation
1. . . .
2. public class CustomerAttrition {
3. . . .
4. //Create and save input objects for build task
5. public void input() throws JDMException {
6. . . .
7. //After creating build task input objects, create test task input objects
8. PhysicalDataSet pdsTest = pdsFactory.create( "CUSTOMERS_TEST_DATA", false );
9. dmeConn.saveObject( "attrition_test_data", pdsTest, replaceExistingObject );
10. }
11. //Create test task and execute it to compute test metrics
12. public boolean run() throws JDMException {
13. . . .
14. //After successful completion of the build task create and execute test task
15. ClassificationTestTaskFactory csTestTaskFactory =
16. (ClassificationTestTaskFactory)dmeConn.getFactory(
17. "javax.datamining.supervised.classification.ClassificationTestTask");
18. ClassificationTestTask csTestTask =
19. csTestTaskFactory.create(
20. "attritionTestData","attrition_model","attrition_testMetrics");
21. dmeConn.saveObject("attrition_test_task", csTestTask, replaceExistingObject);
22. ExcutionStatus testTaskStatus = dmeConn.execute("attrition_test_task", timeOut);
60. if(ExecutionState.success.equals(testTaskStatus.getState()))
61. return true;
62. else
63. return false;
23. }
24. //Retrieve test metrics
25. public void output() throws JDMException {
26. . . .
27. ClassificationTestMetrics clsTestMetrics =
Search WWH ::




Custom Search