BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
GuyTreepwood
Obsidian | Level 7

Hello,

 

I fit a random forest model using the PROC FOREST procedure, and permanently saved the dataset (casuser.RF_Model_V1) using the outmodel = statement in my sample code below. I am able to score other datasets using the saved outmodel dataset (casuser.RF_Model_V1) using the inmodel= statement in PROC FOREST. however, I am not able to create model interpretation stats (i.e. partial dependence plots) using the explainModel.partialDependence action set with that same dataset.

 

proc forest data=casuser.training_data outmodel=casuser.RF_Model_V1;
input var1 var2 var3 var4 / level = interval;
target Target_var / level = nominal;
output out=casuser.score_at_runtime;
ods output FitStatistics=fitstats;
run;

 

The documentation states that in order to get the model interpretation statistics from the explainmodel action set, I would need to call an analytic store (astore) dataset that would have been created using the 'savestate rstore= dataset' statement in PROC FOREST. When I fitted the initial model, I did not create and save the astore dataset. Is there a way to directly convert the saved model from the outmodel= statement to an astore dataset? 

 

1 ACCEPTED SOLUTION

Accepted Solutions
RalphAbbey
SAS Employee

Hi! I think what you're looking for might be the "dtreeExportModel" action in the decisionTree action set. This can take models created using the outmodel option and convert them to the type that you'd see from the savestate statement.

 

I'm not 100% sure of your setup, but try something like this:

proc cas;

action decisionTree.dtreeExportModel / table = {name="RF_Model_V1"}, casout = {name="name_of_model_astore", replace=1}, vote="PROB";

run;

quit;

 

I put the "replace=1" there so that it will overwrite previous tables if they have the same name (use carefully). I also put vote="PROB", which is the default voting method for PROC FOREST. You will want to specify to ensure that the scoring method matches what you expect - probability voting amongst the trees in the forest as opposed to majority voting amongst the trees in the forest.

 

I hope this helps, and feel free to reach out if you have any additional questions!

View solution in original post

3 REPLIES 3
RalphAbbey
SAS Employee

Hi! I think what you're looking for might be the "dtreeExportModel" action in the decisionTree action set. This can take models created using the outmodel option and convert them to the type that you'd see from the savestate statement.

 

I'm not 100% sure of your setup, but try something like this:

proc cas;

action decisionTree.dtreeExportModel / table = {name="RF_Model_V1"}, casout = {name="name_of_model_astore", replace=1}, vote="PROB";

run;

quit;

 

I put the "replace=1" there so that it will overwrite previous tables if they have the same name (use carefully). I also put vote="PROB", which is the default voting method for PROC FOREST. You will want to specify to ensure that the scoring method matches what you expect - probability voting amongst the trees in the forest as opposed to majority voting amongst the trees in the forest.

 

I hope this helps, and feel free to reach out if you have any additional questions!

GuyTreepwood
Obsidian | Level 7

Hello,

 

This solution was mostly correct, and I had to make one slight change...the 'table' statement should actually be 'modelTable'. 

 

proc cas;

action decisionTree.dtreeExportModel / modelTable = {name="RF_Model_V1"}, casout = {name="name_of_model_astore", replace=1}, vote="PROB";

run;

quit;

 

 

RalphAbbey
SAS Employee

That's what I get for not fully checking the doc! Thanks for the correction!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 3 replies
  • 2392 views
  • 0 likes
  • 2 in conversation