Code example

One task can comprise various steps. You can include these steps in one single SQL statement.

For example, the SQL statement for the steps that are outlined in the section Model-building procedure looks like this:
INSERT INTO IDMMX.ClusTasks (ID,TASK)
WITH MyData(MyDataCol) AS ( 
     VALUES(IDMMX.DM_MiningData()..DM_defMiningData('CT'))
)
SELECT 'MyTask',
        IDMMX.DM_ClusBldTask()..DM_defClusBldTask(MyDataCol, 
        IDMMX.DM_ClusSettings()
              ..DM_useClusDataSpec(MyDataCol..DM_genDataSpec())
              ..DM_setMaxNumClus(5))
FROM MyData ; 

This generates the DM_ClusBldTask value, and stores it in the table IDMMX.ClusTasks under the ID MyTask.

You can now start the Clustering training run. Use the stored procedure DM_buildClusModelCmd to compute the Clustering model. This stored procedure can be called from the Db2 command line. It reads the DM_ClusBldTask value from the table IDMMX.ClusTasks, and stores the computed model in the table IDMMX.ClusterModels with the name MyClusModel. This table contains the columns MODELNAME (of type VARCHAR) and MODEL (of type DM_ClusteringModel).

Use the following CALL statement:
CALL IDMMX.DM_buildClusModelCmd( 
    'IDMMX.CLUSTASKS',     'TASK',  'ID',        'MyTask',
    'IDMMX.CLUSTERMODELS', 'MODEL', 'MODELNAME', 'MyClusModel' 
)