Building models with SAS Enterprise Miner, SAS Factory Miner, SAS Visual Data Mining and Machine Learning or just with programming

Finding the name of the winning model programmatically in EM

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 7
Accepted Solution

Finding the name of the winning model programmatically in EM

[ Edited ]

 

Hey all,

 

I'm doing some coding in EM and am leveraging some of the background tables sas generates. To this end, I would need to find the name of the current winning model from a model_comparison node.

 

I want this code to be plug and playable anywhere (so not linked to the workspace or the id name of any other node)

 

For example in order to get the name of the stat explore before it I run the following code:

 

%let stat_nm= %substr(&EM_IMPORT_DATA.,%length(&EM_LIB.)+2,%length(&EM_IMPORT_DATA.) - (%length(&EM_LIB.)+1) - 6);

 

Since &EM_IMPORT_DATA. resolves to

&EM_LIB..(predecesor_node_id)_TRAIN. 

 (which I am enforcing has to be a stat node)

 

I tried doing something similar using &EM_IMPORT_DATA_EMINFO., which resolves to 

&EM_LIB..(WINNING_MOIDEL_NODE_ID)_EMINFO.

 

But for some reason, even though I can see this variable in the macro variable pane ( see below), I get an error that that variable is unitiated when I try to reference it.

 

 

 

 variable_pane.PNG

 

 

 

I also tried using the code noides cmeta_train table which has that information (see code below), this worked at first, but on a subsequent run of the node, this table did not generate and i got an error.

 

proc sql;
	select 
		model into :model_nm separated by ''
	from &EM_LIB..&EM_NODEID._CMETA_TRAIN
		where Role = 'TARGET';
quit;

%let effect_tbl = &EM_LIB..&model_nm._EFFECTS;

 

Below is the set up of my nodes.

 

Please let me know if there is a good way to find the node id of the model that winds the comparison node, or if I can force the cmeta table to generate.

 

P.S. running EM 13.2 on depot 9.04 M2

 

current_flow.PNG


Accepted Solutions
Solution
‎08-19-2016 03:50 PM
SAS Super FREQ
Posts: 306

Re: Finding the name of the winning model programaticaly in EM

Try this:

 

/*Retrieve the Node Id of the Model Comparison node preceding the SAS Code node */
data _null_;
   set &em_lib..em_dgraph;
   if TO="&EM_NODEID" then call symput('mcID',strip(FROM));
run;

/*Retrieve the Node ID of the best model */
data _null_;
  set &em_lib..&mcID._emoutfit;
  where use='Y';
  call symput("bestnode",strip(model));
run;

View solution in original post


All Replies
SAS Super FREQ
Posts: 306

Re: Finding the name of the winning model programaticaly in EM

Not sure if this helps, but you can get the name of the node that was selected as "best" from the MdlComp_Emoutfit data set.  So you can do something like the following in the SAS Code node after the Model Comparison node:

 

 

data _null_;
  set &em_lib..Mdlcomp_emoutfit;
  where use='Y';
  call symput("bestnode",strip(model));
run;

 

 

Then the macro variable bestnode will have the node ID of the modeling node that was chosen.

  

Occasional Contributor
Posts: 7

Re: Finding the name of the winning model programaticaly in EM

Posted in reply to WendyCzika

That helps, but now I would need a way of gettign the name of the mdl_comparison node. I'm invisioning scenarios where there are multiple flows on the same diagram and there are multiple comparison nodes.

Solution
‎08-19-2016 03:50 PM
SAS Super FREQ
Posts: 306

Re: Finding the name of the winning model programaticaly in EM

Try this:

 

/*Retrieve the Node Id of the Model Comparison node preceding the SAS Code node */
data _null_;
   set &em_lib..em_dgraph;
   if TO="&EM_NODEID" then call symput('mcID',strip(FROM));
run;

/*Retrieve the Node ID of the best model */
data _null_;
  set &em_lib..&mcID._emoutfit;
  where use='Y';
  call symput("bestnode",strip(model));
run;
Occasional Contributor
Posts: 7

Re: Finding the name of the winning model programaticaly in EM

Posted in reply to WendyCzika

Awesome thank you I did not know about that table! Smiley Happy

SAS Employee
Posts: 122

Re: Finding the name of the winning model programaticaly in EM

I am saving this post as well. Thanks Wendy. Jason Xin
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 922 views
  • 3 likes
  • 3 in conversation