35.6 The CREATE_MODEL2 Procedure

Shows the settings in the CREATE_MODEL2 procedure.

The CREATE_MODEL2 procedure in the DBMS_DATA_MINING package is a procedure to define model settings and build a model. In the CREATE_MODEL procedure, the input is a table or a view and if such an object is not already present, the user must create it. By using the CREATE_MODEL2 procedure, the user does not need to create such transient database objects. The model can use configuration settings and user-specified transformations.

DBMS_DATA_MINING.CREATE_MODEL2 (     
model_name            IN VARCHAR2,     
mining_function       IN VARCHAR2,     
data_query            IN CLOB,     
set_list              IN SETTING_LIST,     
case_id_column_name   IN VARCHAR2 DEFAULT NULL,     
target_column_name    IN VARCHAR2 DEFAULT NULL,     
xform_list            IN TRANSFORM_LIST DEFAULT NULL);

The data_query parameter species a query which provides training data for building the model. The set_list parameter specifies the SETTING_LIST. SETTING_LIST is a table of CLOB index by VARCHAR2(30); Where the index is the setting name and the CLOB is the setting value for that name. The rest of the parameters are covered in the CREATE.MODEL procedure.

The following CREATE_MODEL2 procedure builds a regression model using GLM algorithm.

DECLARE
    v_setlst DBMS_DATA_MINING.SETTING_LIST;
    BEGIN
    v_setlst('PREP_AUTO') := 'ON';
    v_setlst('ALGO_NAME') := 'ALGO_GENERALIZED_LINEAR_MODEL';
    v_setlst('GLMS_DIAGNOSTICS_TABLE_NAME') := 'GLMR_DIAG';
    v_setlst('GLMS_FTR_SELECTION') := 'GLMS_FTR_SELECTION_ENABLE';
    v_setlst('GLMS_FTR_GENERATION') := 'GLMS_FTR_GENERATION_ENABLE';
     
    DBMS_DATA_MINING.CREATE_MODEL2(
        MODEL_NAME          =>'GLMR_REGR',
        MINING_FUNCTION     =>'REGRESSION',
        DATA_QUERY          =>'SELECT * FROM TRAINING_DATA',
        SET_LIST            =>v_setlst,
        CASE_ID_COLUMN_NAME =>'HID',
        TARGET_COLUMN_NAME  =>'MEDV');
END;