You can apply the Distribution-based Clustering model
to banking data and retrieve the values of the calculated results.
With the result specification, you can define that you are interested
in the best cluster and cluster ID 3.
To apply the sample mining model and to retrieve the results of
applying the model, run the script
bankingApplyResultSpec.db2 by
using the following command:
db2 -stf bankingApplyResultSpec.db2
The sample script
bankingApplyResultSpec.db2 defines
the following common table expressions:
- "RESULTSPECIFICATION"("RESULTSPEC")
- This table expression creates the DM_ResultSpec object
to specify the desired scoring results for each row. Each scoring
result should contain the quality for the cluster ID 3 and the best
cluster.
- "CLUSTERVIEW"("CLIENT_ID","CLUSTERRESULT")
- This table expression contains the results of applying the model.
In this table expression, the sample script applies the DemoBanking model
to selected data from the banking table by using
the DM_applyClusModel function with three parameters.
The third parameter is the result specification object "RESULTSPEC" that
is defined above.
WITH
"RESULTSPECIFICATION"( "RESULTSPEC" ) AS
(
VALUES( IDMMX.DM_ClusResultspec()..DM_setCluster(3)..DM_setBestCluster() )
),
"CLUSTERVIEW"( "CLIENT_ID","CLUSTERRESULT" ) AS
(
SELECT "CLIENT_ID", IDMMX.DM_applyClusModel( 'DemoBanking',
rec2xml( 1.0, 'COLATTVAL', '',
B."AGE",B."GENDER",B."MARITAL_STATUS",B."PROFESSION",B."BANKCARD",
B."NO_CRED_TRANS",B."NO_DEBIT_TRANS" ) ,
R."RESULTSPEC" )
FROM "BANKING_SCORING" B, "RESULTSPECIFICATION" R
)
SELECT "CLIENT_ID", IDMMX.DM_getClusterID( "CLUSTERRESULT" ) AS "BEST_CLUSTER",
CAST( IDMMX.DM_getQuality( "CLUSTERRESULT" ) AS DEC(5,4)) AS "QUALITY_FOR_BEST_CLUSTER",
CAST( IDMMX.DM_getQuality( "CLUSTERRESULT",3 ) AS DEC(5,4)) AS "QUALITY_FOR_CLUSTER_3"
FROM "CLUSTERVIEW" ;
Note: The column names that you specify
in the call to REC2XML must match the names of the
fields that are used in the mining model.