BookmarkSubscribeRSS Feed
andreas_zaras
Pyrite | Level 9
Spoiler
 

Hi!

 

I am using the scorecard node in SAS Viya 3.5. Is there somewhere the chart with the KS statistic in the vertical axis and the scorecard cutoff score in the horizontal axis (to get the optimal scorecard cut off) as it was in SAS EM scorecard node?

 

Thanks in adavnce,

 

Andreas

7 REPLIES 7
andreas_zaras
Pyrite | Level 9
If not where can we see the cutoff score used by the node to classify goods from bads?
Ksharp
Super User
cutoff score is making confusion matrix most distinguish(or when K-S statistic is max) .
you could also wrote data step to get it .
andreas_zaras
Pyrite | Level 9
Can we see at which score the KS statistic is max in a graph e.g. ROC curve?
Ksharp
Super User

Here is the code I wrote before to get max K-S value .

Note: using all data you can get  . Not the training data of building scorecard.

 

/****** Get cutpoint ******/
proc delete data=cutpoint;run;
%macro cutpoint;
%do score=&score_min %to &score_max;
data test_total_score;
 set score_card;
 _status=ifc(total_score ge &score,'good','bad ');
run;
proc npar1way data=test_total_score edf noprint;
class _status;
var total_score;
output out=cutpoint_ks(keep=_KS_) edf;
run;
data temp_cutpoint;
 retain cutpoint &score ;
 set cutpoint_ks ;
 label cutpoint='分割点' _ks_='KS值';
run;
proc append base=cutpoint data=temp_cutpoint force;run;
%end;
%mend;

%cutpoint

proc sql noprint;
select cutpoint into : cutpoint
 from cutpoint
  having _KS_=max(_KS_);
quit;
data _null_;
 set cutpoint end=last;
 if _n_=1 then call symputx('min',cutpoint);
 if last then call symputx('max',cutpoint);
run;















data final_total_score;
 set score_card;
 *_status=ifc(total_score ge &cutpoint,'good','bad ');
run;


/*********** Confused Matrix  **********/
/*********** Also Check Validate Table **********/
title "训练集分割点为 &cutpoint 的混淆矩阵 - Confused Matrix";
proc freq data=final_total_score  ;
table good_bad*_status/nopercent  norow  contents=' ';
label good_bad='实际值' _status='预测值';
run;
title ' ';


/********* Graph for cutpoint and KS value *************/
data plot_cutpoint;
 set cutpoint;
 if cutpoint=&cutpoint then group=1;
  else group=0;
run;
proc sgplot data=plot_cutpoint noautolegend;
needle x=cutpoint y=_ks_ /group=group ;
yaxis  LABELATTRS=graphdata1 VALUEATTRS=graphdata1 ;
xaxis values=(&min &cutpoint &max);
run;

title "KS检验";
proc npar1way data=final_total_score plots=edfplot edf ;
class good_bad;
var total_score;
run;
title ' ';


/*********** Graph for Score Card  *************/
data plot_bad_percent;
 set report;
 length range $ 40;
 range=cats('[',put(int(min),8.0),',',put(int(max),8.0),']');
run;

proc sgplot data=plot_bad_percent ;
series x=range y=percent_bad/datalabel markers MARKERATTRS=(symbol=circlefilled
  size=12) MARKERFILLATTRS=(color=white) MARKEROUTLINEATTRS=graphdata1
  FILLEDOUTLINEDMARKERS DATALABELPOS=right datalabelattrs=(size=10);
xaxistable n_good n /valueattrs=(size=10);
label n='人数' ;
xaxis  FITPOLICY=stagger label='评分' labelposition=left
 LABELATTRS=graphdata1 VALUEATTRS=graphdata1(size=10) grid;
format percent_bad percent7.2;
run;
andreas_zaras
Pyrite | Level 9
I was wondering wether there is a ROC curve graph to see the KS statistics like there was in SAS EM Credit Scoring nodes.

Thanks,

Andreas
Ksharp
Super User

I don't understand. 

You want this ?

 

proc logistic data=sashelp.class;
model sex=weight height/outroc=roc ;
run;

proc sgplot data=roc aspect=1 noautolegend; 
series y=_SENSIT_ x=_1MSPEC_;
lineparm x=0 y=0 slope=1;
inset 'KS=0.324';
run;

Ksharp_0-1629025918983.png

 

andreas_zaras
Pyrite | Level 9
Hi!

I wanted this as a standard output in SAS VDMM (without having to wrote sas code).

BR,

Andreas

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 1265 views
  • 3 likes
  • 2 in conversation