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

Hello All,

I've created a small model using Proc HPFOREST and scored using HP4SCORE (code below).

Is there anyway I can export the Random Forest SAS code with actual model?

 

I need to implement this model in a platform other than SAS and as such I need the SAS code for model itself.

 

Thank you,

Marcelo

 

proc hpforest data= train leafsize=20;

   target survived / level= binary;

   input SibSp Parch / level= binary;

   input age / level= interval;

   input sex / level= nominal;

 

   ods output fitstatistics = fitstats;

   save file = "c:\temp\model_fit.bin";

run;

 

proc surveyselect data= train

   method=srs N=100 out= samp;

run;

 

proc hp4score data=samp;

   id survived;

   score file= "c:\temp\model_fit.bin"

   out=scored;

   performance details;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
WendyCzika
SAS Employee

Actually you can't get SAS Data step, C, Java, or PMML score code for HP Forest models.  You need to use either the HP4SCORE or ASTORE procedures.

 

This tip has information about scoring with PROC ASTORE:

https://communities.sas.com/t5/SAS-Communities-Library/SAS-High-Performance-Analytics-tip-5-Scoring-...

 

And if you are trying to score data in a database, this tip walks through how to use the score code (with HP4SCORE) to score distributed data: https://communities.sas.com/t5/SAS-Communities-Library/Tip-How-Can-I-Apply-HP-Forest-Score-Code-to-D...

 

View solution in original post

8 REPLIES 8
Reeza
Super User

If you have SAS EM you can export your score code into SAS, You can also get a PMML, C or Java score code. 

 

I can't access the docs but look for a CODE statement to see if that will generate the SAS code for you. 

 

marcelo_higasi
Fluorite | Level 6

 Hi Reeza,

Thank you for helping.

 

I do not have EM either. I can run HPForest in SAS code only because my license has access to the High Performnce module.

 

I've tried the seraching for "code" statements. What I found was something like "code file = <file location>" but it does not seem to work with HPforest. Or maybe I do know the correct syntax.

 

Would yoy have any other suggestion?

 

Thank you 

Reeza
Super User

Is there a RULES statement?

What does the following show? 

 

Proc setinit;

proc product_status;

run;

 

HPFOREST isn't listed under HP Stat procedures...I'm mostly curious here. 

marcelo_higasi
Fluorite | Level 6

Intersting, it appears that I do have license for EM

---SAS Enterprise Miner Server/Client v13.1

However I do not have acces to it.

 

I believe I am able to run HPForest because I also have access to

---High Performance Suite v2.2

 

 

I cannot find any good syntax reference for HPforest or HP4score.

Do you have an example of RULES statement fir HPforest or HP4Score?

 

Thanks again

WendyCzika
SAS Employee

Actually you can't get SAS Data step, C, Java, or PMML score code for HP Forest models.  You need to use either the HP4SCORE or ASTORE procedures.

 

This tip has information about scoring with PROC ASTORE:

https://communities.sas.com/t5/SAS-Communities-Library/SAS-High-Performance-Analytics-tip-5-Scoring-...

 

And if you are trying to score data in a database, this tip walks through how to use the score code (with HP4SCORE) to score distributed data: https://communities.sas.com/t5/SAS-Communities-Library/Tip-How-Can-I-Apply-HP-Forest-Score-Code-to-D...

 

marcelo_higasi
Fluorite | Level 6

Thanks very much for your help Wendy.

 

I've come across HP4score and it works fine. My challenge is to produce code out of an HPforest procedure which can be used to implement the model outside of SAS (using C++ for instance). Based on your response this does not seem possible.

 

I've tried HPneural and it seems like is can output as SAS code "score out=survived_score"; It would handy if this statement was also available in HPforrest.

 

Thank you again.

WendyCzika
SAS Employee

The HPFOREST procedure does also support a SCORE statement where you can specify the output (scored) data set.  

MaheshP
Calcite | Level 5

I have added the below two lines to my Random Forest Code:

 

   ods output fitstatistics = fitstats;

   save file = "c:\temp\model_fit.bin";

 

 

I get the below error:

 

Unable to open model file for writing.

 

Why am I seeing this error? How can I get rid of it?

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 8 replies
  • 9530 views
  • 5 likes
  • 4 in conversation