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;
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:
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...
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.
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
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.
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
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:
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...
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.
The HPFOREST procedure does also support a SCORE statement where you can specify the output (scored) data set.
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.