/*START_NOCLEAN_*/ *--------------------------------------------------------------*; * ENSEMBLE T3TKAB0I : score code; *--------------------------------------------------------------*; *; * BOOSTING: counter= 1; *; * Temporary variables; DROP B_T3TKAB0I_P_BAD1; DROP B_T3TKAB0I_P_BAD0; B_T3TKAB0I_P_BAD1= 0.0; B_T3TKAB0I_P_BAD0= 0.0; *-------------------------------------------------------------*; * CODE_CLEAN * *; * Code substitution: ARRAY RGDRF->A9086 *; * Code substitution: ARRAY RGDRU->A7179 *; * Code substitution: GOTO RGDR1->G5074 *; * Code substitution: ARRAY RGDEMA->A25515 *; * Code substitution: GOTO RGDEEX->G31247 *; * Code substitution: ARRAY RGDEBE->A11623 *; *-------------------------------------------------------------*; *-------------------------------------------------------------*; * START_CHUNK 1491261002.3:T3HD8QE7 *; *-------------------------------------------------------------*; * ; * TOOL : Input Data Source ; * TYPE : SAMPLING ; * NODE : SAMPSIO.HMEQ [T3HD8QE7] ; * ; *-------------------------------------------------------------*; *-------------------------------------------------------------*; * END_CHUNK 1491261002.3:T3HD8QE7 *; *-------------------------------------------------------------*; *-------------------------------------------------------------*; * START_CHUNK 1491261353.6:T0TUJP09 *; *-------------------------------------------------------------*; * END_CHUNK 1491261353.6:T0TUJP09 *; *-------------------------------------------------------------*; *-------------------------------------------------------------*; * START_CHUNK 1491261354.1:T0R9VVV_ *; /*Index: 1*/ /*Boostrap-Boosting*/ *-------------------------------------------------------------*; * ; * TOOL : Group Processing ; * TYPE : UTILITY ; * NODE : Group Processing [Boosting] [T0R9VVV_] ; * ; *-------------------------------------------------------------*; DO; *-------------------------------------------------------------*; * END_CHUNK 1491261354.1:T0R9VVV_ *; *-------------------------------------------------------------*; *-------------------------------------------------------------*; * START_CHUNK 1491261355:T2N8GQ9L *; *-------------------------------------------------------------*; * ; * TOOL : Variable Selection ; * TYPE : EXPLORE ; * NODE : Variable Selection [T2N8GQ9L] ; * ; *-------------------------------------------------------------*; length _warn_ $ 4; label _warn_ = "Warnings"; length _norm1 $ %DMNORLEN; _norm1 = ' '; length _FORMAT $200; drop _FORMAT; length I_BAD $ 1; _PVAL = 0.94709373640813; if DELINQ = . then _PVAL = _PVAL + (0.4614670380687 * -0.10735405331816); else _PVAL = _PVAL + (DELINQ * -0.10735405331816); if DEROG = . then _PVAL = _PVAL + (0.24098671726755 * -0.09072108146071); else _PVAL = _PVAL + (DEROG * -0.09072108146071); if NINQ = . then _PVAL = _PVAL + (1.15148741418764 * -0.02971397992002); else _PVAL = _PVAL + (NINQ * -0.02971397992002); if CLAGE = . then _PVAL = _PVAL + (183.082121017779 * 0.00052746440928); else _PVAL = _PVAL + (CLAGE * 0.00052746440928); if DEBTINC = . then _PVAL = _PVAL + (33.8504561863834 * -0.00443445751451); else _PVAL = _PVAL + (DEBTINC * -0.00443445751451); if YOJ = . then _PVAL = _PVAL + (8.88625971650663 * 0.00238659155642); else _PVAL = _PVAL + (YOJ * 0.00238659155642); /* binary target */ if _warn_ ne 'U' then do; _X = -(-4.07334588668761 + 7.1153598149959 * _PVAL); if (_X < -23) then _PVAL = 1; else if (_X > 23) then _PVAL = 0; else _PVAL = 1/(1+exp(_X)); if _PVAL < 0 then _PVAL = 1; else if _PVAL > 1 then _PVAL = 0; else _PVAL = 1 - _PVAL; P_EVENT = _PVAL; P_NEVENT = 1-P_EVENT; if P_EVENT ge 0.5 then I_BAD = '1'; else I_BAD = '0'; end; else do; P_EVENT = 0.19085570469798; P_NEVENT = 0.80914429530201; I_BAD = '0'; end; label P_EVENT = "Predicted: EVENT for BAD"; label P_NEVENT = "Predicted: NO EVENT for BAD"; label I_BAD = "Into: BAD"; DROP _PVAL _X; DROP _NORM1; *-------------------------------------------------------------*; * END_CHUNK 1491261355:T2N8GQ9L *; *-------------------------------------------------------------*; *-------------------------------------------------------------*; * START_CHUNK 1491261366.8:T3PO36GV *; *-------------------------------------------------------------*; * ; * TOOL : Regression ; * TYPE : MODEL ; * NODE : Regression [T3PO36GV] ; * ; *-------------------------------------------------------------*; * ; * MODEL NAME : Untitled ; * DESCRIPTION : ; * ; * TARGET : BAD ; *-------------------------------------------------------------*; *************************************; *** begin scoring code for regression; *************************************; length _WARN_ $4; label _WARN_ = 'Warnings' ; length I_BAD $ 12; label I_BAD = 'Into: BAD' ; *** Target Values; array A9086 [2] $12 _temporary_ ('1' '0' ); label U_BAD = 'Unnormalized Into: BAD' ; *** Unnormalized target values; ARRAY A7179[2] _TEMPORARY_ (1 0); *** Generate dummy variables for BAD ; drop _Y ; label F_BAD = 'From: BAD' ; length F_BAD $ 12; F_BAD = put( BAD , BEST12. ); %DMNORMIP( F_BAD ) if missing( BAD ) then do; _Y = .; end; else do; if F_BAD = '0' then do; _Y = 1; end; else if F_BAD = '1' then do; _Y = 0; end; else do; _Y = .; end; end; drop _DM_BAD; _DM_BAD=0; *** Check DEROG for missing values ; if missing( DEROG ) then do; substr(_warn_,1,1) = 'M'; _DM_BAD = 1; end; *** Check NINQ for missing values ; if missing( NINQ ) then do; substr(_warn_,1,1) = 'M'; _DM_BAD = 1; end; *** Check YOJ for missing values ; if missing( YOJ ) then do; substr(_warn_,1,1) = 'M'; _DM_BAD = 1; end; *** Check DELINQ for missing values ; if missing( DELINQ ) then do; substr(_warn_,1,1) = 'M'; _DM_BAD = 1; end; *** Check CLAGE for missing values ; if missing( CLAGE ) then do; substr(_warn_,1,1) = 'M'; _DM_BAD = 1; end; *** Check DEBTINC for missing values ; if missing( DEBTINC ) then do; substr(_warn_,1,1) = 'M'; _DM_BAD = 1; end; *** If missing inputs, use averages; if _DM_BAD > 0 then do; _P0 = 0.0865006553; _P1 = 0.9134993447; goto G5074; end; *** Compute Linear Predictor; drop _TEMP; drop _LP0; _LP0 = 0; *** Effect: DEROG ; _TEMP = DEROG ; _LP0 = _LP0 + ( 0.67391732647166 * _TEMP); *** Effect: NINQ ; _TEMP = NINQ ; _LP0 = _LP0 + ( 0.26877376694198 * _TEMP); *** Effect: YOJ ; _TEMP = YOJ ; _LP0 = _LP0 + ( -0.01939994619464 * _TEMP); *** Effect: DELINQ ; _TEMP = DELINQ ; _LP0 = _LP0 + ( 0.87320002120243 * _TEMP); *** Effect: CLAGE ; _TEMP = CLAGE ; _LP0 = _LP0 + ( -0.00420579762709 * _TEMP); *** Effect: DEBTINC ; _TEMP = DEBTINC ; _LP0 = _LP0 + ( 0.07089603937264 * _TEMP); *** Naive Posterior Probabilities; drop _MAXP _IY _P0 _P1; _TEMP = -4.96857154052557 + _LP0; if (_TEMP < 0) then do; _TEMP = exp(_TEMP); _P0 = _TEMP / (1 + _TEMP); end; else _P0 = 1 / (1 + exp(-_TEMP)); _P1 = 1.0 - _P0; G5074: *** Residuals; if (_Y = .) then do; R_BAD1 = .; R_BAD0 = .; end; else do; label R_BAD1 = 'Residual: BAD=1' ; label R_BAD0 = 'Residual: BAD=0' ; R_BAD1 = - _P0; R_BAD0 = - _P1; select( _Y ); when (0) R_BAD1 = R_BAD1 + 1; when (1) R_BAD0 = R_BAD0 + 1; end; end; *** Update Posterior Probabilities; *** Decision Processing; label D_BAD1_ = 'Decision: BAD' ; label EP_BAD1_ = 'Expected Profit: BAD' ; label BP_BAD1_ = 'Best Profit: BAD' ; label CP_BAD1_ = 'Computed Profit: BAD' ; length D_BAD1_ $ 5; D_BAD1_ = ' '; EP_BAD1_ = .; BP_BAD1_ = .; CP_BAD1_ = .; *** Compute Expected Consequences and Choose Decision; _decnum = 1; drop _decnum; D_BAD1_ = '1' ; EP_BAD1_ = _P0 * 1 + _P1 * 0; *** Decision Matrix; array A25515 [2,1] _temporary_ ( /* row 1 */ 1 /* row 2 */ 0 ); *** Find Index of Target Category; drop _tarnum; select( F_BAD ); when('1' ) _tarnum = 1; when('0' ) _tarnum = 2; otherwise _tarnum = 0; end; if _tarnum <= 0 then goto G31247; *** Computed Consequence of Chosen Decision; CP_BAD1_ = A25515 [_tarnum,_decnum]; *** Best Possible Consequence of Any Decision without Cost; array A11623 [2] _temporary_ ( 1 0); BP_BAD1_ = A11623 [_tarnum]; G31247:; *** End Decision Processing ; *** Posterior Probabilities and Predicted Level; label P_BAD1 = 'Predicted: BAD=1' ; label P_BAD0 = 'Predicted: BAD=0' ; P_BAD1 = _P0; _MAXP = _P0; _IY = 1; P_BAD0 = _P1; if (_P1 - _MAXP > 1e-8) then do; _MAXP = _P1; _IY = 2; end; I_BAD = A9086[_IY]; U_BAD = A7179[_IY]; *************************************; ***** end scoring code for regression; *************************************; *-------------------------------------------------------------*; * END_CHUNK 1491261366.8:T3PO36GV *; *-------------------------------------------------------------*; *; * ENSEMBLE T3TKAB0I : End of Looping DO block; END; *; *; * BOOSTING: save probabilities for next iteration; B_T3TKAB0I_P_BAD1= P_BAD1; B_T3TKAB0I_P_BAD0= P_BAD0; *-------------------------------------------------------------*; * CODE_CLEAN * *; * Code substitution: ARRAY RG2DRF->A95501 *; * Code substitution: ARRAY RG2DRU->A89414 *; * Code substitution: GOTO RG2DR1->G05469 *; * Code substitution: ARRAY RG2DEMA->A389124 *; * Code substitution: GOTO RG2DEEX->G393410 *; * Code substitution: ARRAY RG2DEBE->A165710 *; *-------------------------------------------------------------*; *-------------------------------------------------------------*; * START_CHUNK 1491261371.2:T0R9VVV_ *; /*Index: 2*/ /*Boostrap-Boosting*/ *-------------------------------------------------------------*; * ; * TOOL : Group Processing ; * TYPE : UTILITY ; * NODE : Group Processing [Boosting] [T0R9VVV_] ; * ; *-------------------------------------------------------------*; DO; *-------------------------------------------------------------*; * END_CHUNK 1491261371.2:T0R9VVV_ *; *-------------------------------------------------------------*; *-------------------------------------------------------------*; * START_CHUNK 1491261372.3:T2N8GQ9L *; *-------------------------------------------------------------*; * ; * TOOL : Variable Selection ; * TYPE : EXPLORE ; * NODE : Variable Selection [T2N8GQ9L] ; * ; *-------------------------------------------------------------*; length _warn_ $ 4; label _warn_ = "Warnings"; length _norm1 $ %DMNORLEN; _norm1 = ' '; length _FORMAT $200; drop _FORMAT; length I_BAD $ 1; _PVAL = 0.04593670026768; if NINQ = . then _PVAL = _PVAL + (1.25619195046438 * 0.01315978293176); else _PVAL = _PVAL + (NINQ * 0.01315978293176); if YOJ = . then _PVAL = _PVAL + (8.67846391354662 * -0.00301966556235); else _PVAL = _PVAL + (YOJ * -0.00301966556235); if MORTDUE = . then _PVAL = _PVAL + (72457.2023672978 * -3.0720213836745E-7); else _PVAL = _PVAL + (MORTDUE * -3.0720213836745E-7); /* binary target */ if _warn_ ne 'U' then do; _X = -(-4.77814081615569 + 23.9391159858531 * _PVAL); if (_X < -23) then _PVAL = 1; else if (_X > 23) then _PVAL = 0; else _PVAL = 1/(1+exp(_X)); if _PVAL < 0 then _PVAL = 1; else if _PVAL > 1 then _PVAL = 0; else _PVAL = 1 - _PVAL; P_EVENT = _PVAL; P_NEVENT = 1-P_EVENT; if P_EVENT ge 0.5 then I_BAD = '1'; else I_BAD = '0'; end; else do; P_EVENT = 0.31181269953884; P_NEVENT = 0.68818730046115; I_BAD = '0'; end; label P_EVENT = "Predicted: EVENT for BAD"; label P_NEVENT = "Predicted: NO EVENT for BAD"; label I_BAD = "Into: BAD"; DROP _PVAL _X; DROP _NORM1; *-------------------------------------------------------------*; * END_CHUNK 1491261372.3:T2N8GQ9L *; *-------------------------------------------------------------*; *-------------------------------------------------------------*; * START_CHUNK 1491261384.5:T3PO36GV *; *-------------------------------------------------------------*; * ; * TOOL : Regression ; * TYPE : MODEL ; * NODE : Regression [T3PO36GV] ; * ; *-------------------------------------------------------------*; * ; * MODEL NAME : Untitled ; * DESCRIPTION : ; * ; * TARGET : BAD ; *-------------------------------------------------------------*; *************************************; *** begin scoring code for regression; *************************************; length _WARN_ $4; label _WARN_ = 'Warnings' ; length I_BAD $ 12; label I_BAD = 'Into: BAD' ; *** Target Values; array A95501 [2] $12 _temporary_ ('1' '0' ); label U_BAD = 'Unnormalized Into: BAD' ; *** Unnormalized target values; ARRAY A89414[2] _TEMPORARY_ (1 0); *** Generate dummy variables for BAD ; drop _Y ; label F_BAD = 'From: BAD' ; length F_BAD $ 12; F_BAD = put( BAD , BEST12. ); %DMNORMIP( F_BAD ) if missing( BAD ) then do; _Y = .; end; else do; if F_BAD = '0' then do; _Y = 1; end; else if F_BAD = '1' then do; _Y = 0; end; else do; _Y = .; end; end; drop _DM_BAD; _DM_BAD=0; *** Check NINQ for missing values ; if missing( NINQ ) then do; substr(_warn_,1,1) = 'M'; _DM_BAD = 1; end; *** Check YOJ for missing values ; if missing( YOJ ) then do; substr(_warn_,1,1) = 'M'; _DM_BAD = 1; end; *** Check MORTDUE for missing values ; if missing( MORTDUE ) then do; substr(_warn_,1,1) = 'M'; _DM_BAD = 1; end; *** If missing inputs, use averages; if _DM_BAD > 0 then do; _P0 = 0.309865276; _P1 = 0.690134724; goto G05469; end; *** Compute Linear Predictor; drop _TEMP; drop _LP0; _LP0 = 0; *** Effect: NINQ ; _TEMP = NINQ ; _LP0 = _LP0 + ( 0.22937801200803 * _TEMP); *** Effect: YOJ ; _TEMP = YOJ ; _LP0 = _LP0 + ( -0.02804817864407 * _TEMP); *** Effect: MORTDUE ; _TEMP = MORTDUE ; _LP0 = _LP0 + ( -3.8721205436057E-6 * _TEMP); *** Naive Posterior Probabilities; drop _MAXP _IY _P0 _P1; _TEMP = -0.59555117367739 + _LP0; if (_TEMP < 0) then do; _TEMP = exp(_TEMP); _P0 = _TEMP / (1 + _TEMP); end; else _P0 = 1 / (1 + exp(-_TEMP)); _P1 = 1.0 - _P0; G05469: *** Residuals; if (_Y = .) then do; R_BAD1 = .; R_BAD0 = .; end; else do; label R_BAD1 = 'Residual: BAD=1' ; label R_BAD0 = 'Residual: BAD=0' ; R_BAD1 = - _P0; R_BAD0 = - _P1; select( _Y ); when (0) R_BAD1 = R_BAD1 + 1; when (1) R_BAD0 = R_BAD0 + 1; end; end; *** Update Posterior Probabilities; *** Decision Processing; label D_BAD1_ = 'Decision: BAD' ; label EP_BAD1_ = 'Expected Profit: BAD' ; label BP_BAD1_ = 'Best Profit: BAD' ; label CP_BAD1_ = 'Computed Profit: BAD' ; length D_BAD1_ $ 5; D_BAD1_ = ' '; EP_BAD1_ = .; BP_BAD1_ = .; CP_BAD1_ = .; *** Compute Expected Consequences and Choose Decision; _decnum = 1; drop _decnum; D_BAD1_ = '1' ; EP_BAD1_ = _P0 * 1 + _P1 * 0; *** Decision Matrix; array A389124 [2,1] _temporary_ ( /* row 1 */ 1 /* row 2 */ 0 ); *** Find Index of Target Category; drop _tarnum; select( F_BAD ); when('1' ) _tarnum = 1; when('0' ) _tarnum = 2; otherwise _tarnum = 0; end; if _tarnum <= 0 then goto G393410; *** Computed Consequence of Chosen Decision; CP_BAD1_ = A389124 [_tarnum,_decnum]; *** Best Possible Consequence of Any Decision without Cost; array A165710 [2] _temporary_ ( 1 0); BP_BAD1_ = A165710 [_tarnum]; G393410:; *** End Decision Processing ; *** Posterior Probabilities and Predicted Level; label P_BAD1 = 'Predicted: BAD=1' ; label P_BAD0 = 'Predicted: BAD=0' ; P_BAD1 = _P0; _MAXP = _P0; _IY = 1; P_BAD0 = _P1; if (_P1 - _MAXP > 1e-8) then do; _MAXP = _P1; _IY = 2; end; I_BAD = A95501[_IY]; U_BAD = A89414[_IY]; *************************************; ***** end scoring code for regression; *************************************; *-------------------------------------------------------------*; * END_CHUNK 1491261384.5:T3PO36GV *; *-------------------------------------------------------------*; *; * ENSEMBLE T3TKAB0I : End of Looping DO block; END; *; *; * BOOSTING: accumulate probabilities : counter= 2; P_BAD1= P_BAD1*(1/2) + B_T3TKAB0I_P_BAD1*(1/2); P_BAD0= P_BAD0*(1/2) + B_T3TKAB0I_P_BAD0*(1/2); *; * BOOSTING: save probabilities for next iteration; B_T3TKAB0I_P_BAD1= P_BAD1; B_T3TKAB0I_P_BAD0= P_BAD0; *--------------------------------------------------------------*; * Ensemble: BAD: Classification Vars; *--------------------------------------------------------------*; length I_BAD $32; length F_BAD $32; label I_BAD = "Into: BAD"; label F_BAD = "From: BAD"; length _format $200; drop _format; _format= PUT( BAD, BEST12. ); %DMNORMCP(_format,F_BAD); _format= ' '; _p_= 0; drop _p_; if P_BAD1 > _p_ then do ; _p_= P_BAD1 ; _format= " 1" ; end ; if P_BAD0 > _p_ then do ; _p_= P_BAD0 ; _format= " 0" ; end ; %DMNORMCP(_format,I_BAD); *; *--------------------------------------------------------------*; * Ensemble: BAD: Decisions; *--------------------------------------------------------------*; *** Warning Variable; length _warn_ $4; label _warn_ = 'Warnings'; drop _decwarn; _decwarn = 0; *** Check Posterior Probabilities; if not (n( P_BAD1 ) & ( P_BAD1 <= 1) & (0 <= P_BAD1 ) & n( P_BAD0 ) & ( P_BAD0 <= 1) & (0 <= P_BAD0 ) ) then do; _decwarn = 1; substr(_warn_,3,1) = 'P'; P_BAD1 = .; P_BAD0 = .; goto _demi; end; *** Update Posterior Probabilities; P_BAD1 = P_BAD1 * 0.19085570469798 / 0.19085570469798; P_BAD0 = P_BAD0 * 0.80914429530201 / 0.80914429530201; drop _sum; _sum = P_BAD1 + P_BAD0 ; if _sum > 0 then do; P_BAD1 = P_BAD1 / _sum; P_BAD0 = P_BAD0 / _sum; end; *** Decision Processing; label D_BAD1_ = 'Decision: BAD' ; label EP_BAD1_ = 'Expected Profit: BAD' ; label BP_BAD1_ = 'Best Profit: BAD' ; label CP_BAD1_ = 'Computed Profit: BAD' ; length D_BAD1_ $ 5; *** Initialize to Missing if Target Used; _demi:; D_BAD1_ = ' '; EP_BAD1_ = .; BP_BAD1_ = .; CP_BAD1_ = .; if _decwarn then goto _deex; *** Compute Expected Consequences and Choose Decision; _decnum = 1; drop _decnum; D_BAD1_ = '1' ; EP_BAD1_ = P_BAD1 * 1 + P_BAD0 * 0; *** Decision Matrix; array _dema [2,1] _temporary_ ( /* row 1 */ 1 /* row 2 */ 0 ); *** Normalize Target Value; length _targnor $ %DMNORLEN; drop _targnor; length _format $200; drop _format; _format = put( BAD , BEST12. ); %DMNORMCP(_format,_targnor); *** Find Index of Target Category; drop _tarnum; select( _targnor ); when('1' ) _tarnum = 1; when('0' ) _tarnum = 2; otherwise _tarnum = 0; end; if _tarnum <= 0 then goto _deex; *** Computed Consequence of Chosen Decision; CP_BAD1_ = _dema [_tarnum,_decnum]; *** Best Possible Consequence of Any Decision without Cost; array _debe [2] _temporary_ ( 1 0); BP_BAD1_ = _debe [_tarnum]; _deex:; *** End Decision Processing ; *--------------------------------------------------------------*; * ENSEMBLE T3TKAB0I - END OF CODE; *--------------------------------------------------------------*; /*END_NOCLEAN_*/