随笔 - 589  文章 - 0 评论 - 116 trackbacks - 5

逻辑回归预测分析编程规范(模型):http://www.cnblogs.com/omygod/archive/2013/05/15/3080437.html

逻辑回归预测分析编程规范(预测):http://www.cnblogs.com/omygod/archive/2013/05/15/3080441.html

 

 

-- PAL setup
SET SCHEMA _SYS_AFL;
CREATE TYPE PAL_T_RGEL_DATA AS TABLE (LIFESPEND INTEGER, GENDER INTEGER);
truncate table PAL_RG_SIGNATURE;
INSERT INTO PAL_RG_SIGNATURE VALUES (1, 'PAL_T_RGEL_DATA', 'in');
INSERT INTO PAL_RG_SIGNATURE VALUES (2, 'PAL_T_RG_PARAMS', 'in');
INSERT INTO PAL_RG_SIGNATURE VALUES (3, 'PAL_T_RG_COEFF', 'out');
INSERT INTO PAL_RG_SIGNATURE VALUES (4, 'PAL_T_RG_PMML', 'out');
--call system.AFL_WRAPPER_ERASER ('PAL_RG');
CALL SYSTEM.AFL_WRAPPER_GENERATOR ('PAL_RGEL', 'AFLPAL', 'LOGISTICREGRESSION', PAL_RG_SIGNATURE);

-- app setup
SET SCHEMA PAL;
--drop view V_RG_DATA;
CREATE VIEW V_RGEL_DATA AS
    SELECT TOP 1000 l.LIFESPEND, c.CUSTOMER_GENDER_ID AS GENDER
     FROM CUSTOMER c
     INNER JOIN (
            SELECT CUSTOMER_ID, SUM(SALES_AMOUNT) AS LIFESPEND
             FROM ORDER_FACTS
             GROUP BY CUSTOMER_ID
                ) l ON(c.CUSTOMER_ID = l.CUSTOMER_ID)
     ;

truncate table RG_PARAMS;
INSERT INTO RG_PARAMS VALUES ('THREAD_NUMBER', 2, null, null);
INSERT INTO RG_PARAMS VALUES ('MAX_ITERATION', 1000, null, null);
INSERT INTO RG_PARAMS VALUES ('EXIT_THRESHOLD', null, 0.00001, null);
INSERT INTO RG_PARAMS VALUES ('VARIABLE_NUM', 1, null, null);
INSERT INTO RG_PARAMS VALUES ('METHOD', 0, null, null);
INSERT INTO RG_PARAMS VALUES ('PMML_EXPORT', 2, null, null);
--INSERT INTO RG_PARAMS VALUES ('STEP_SIZ', 100, null, null);

-- app runtime
SET SCHEMA PAL;
TRUNCATE TABLE RG_COEFF;
TRUNCATE TABLE RG_PMML;

CALL _SYS_AFL.PAL_RGEL (V_RGEL_DATA, RG_PARAMS, RG_COEFF, RG_PMML) WITH OVERVIEW;


select *   from V_RG_DATA
select * from RG_COEFF

posted on 2013-05-16 10:52  沧海-重庆  阅读(1095)  评论(0编辑  收藏