Working with a Classification test result

In this exercise, you extract information from the created Classification test result.

Use the following command to run the sample script heartClasTestResult.db2 to extract information from the created Classification test result:
db2 -stf heartClasTestResult.db2
The first part of the sample script heartClasTestResult.db2 contains a SELECT statement that reads the Classification error and model quality indicators from the result of a Classification test run:
SELECT 
  CAST (IDMMX.DM_getClasError("RESULT") AS DEC(5,2))
              AS "CLASSIFICATION_ERROR",'%' AS "%",
  CAST (IDMMX.DM_getMdlQuality("RESULT") AS DEC(5,2)) 
              AS "MODEL_QUALITY",
  CAST (IDMMX.DM_getReliability("RESULT") AS DEC(5,2)) 
              AS "RELIABILITY",
  CAST (IDMMX.DM_getRankQuality("RESULT",'2') AS DEC(5,2)) 
              AS "RANK_QUALITY",
  CAST (IDMMX.DM_getPredAccuracy("RESULT",'2') AS DEC(5,2)) 
              AS "PRED_ACCURACY"
FROM IDMMX."CLASTESTRESULTS"
WHERE "ID"='HeartClasTestResult';
The next part of the sample script contains a SELECT statement that reads the confusion matrix from the result of a Classification test run. Classifications are divided into actual and predicted values.
SELECT CAST ("ACTUAL" AS CHAR(15)) AS "ACTUAL_VALUE",
       CAST ("PREDICTED" AS CHAR(15)) AS "PREDICTED_VALUE",
       "COUNT" AS "NUM_CASES",
       "COST" AS "COST_OF_WRONG_PREDICTION"
FROM TABLE (IDMMX.DM_getConfMatrix(
  (SELECT "RESULT" FROM IDMMX."CLASTESTRESULTS" 
   WHERE ID='HeartClasTestResult'))
) AS "MATRIX"
ORDER BY "ACTUAL", "PREDICTED";
The following part of the sample script contains a SELECT statement that reads the gains chart information from the result of a Classification test run:
SELECT CAST ("ROWCOUNT" AS SMALLINT) AS "NUMROWS_IN_SUBSET",
       CAST ("SUMACTUAL" AS SMALLINT) AS "NUMROWS_DISEASED_IS_2",
       CAST ("THRESHOLD" AS DEC(5,2)) 
                         AS "SMALLEST_CONFIDENCE_IN_SUBSET"
FROM TABLE (IDMMX.DM_getGainsChart(
  (SELECT "RESULT" FROM IDMMX."CLASTESTRESULTS" 
   WHERE ID='HeartClasTestResult'),'2')
) AS "MATRIX"                                  
ORDER BY "NUMROWS_IN_SUBSET";


Feedback | Information roadmap