BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
KeanuHua4
Calcite | Level 5

I am running PROC HPBNET on regular SAS for Naive Bayes classification. Not Viya, not Enterprise Miner. If necessary, I can switch to Enterprise Miner, but I would strongly prefer not to. PROC HPBNET has run completely fine on regular SAS insofar.

 

I have a data set split between train and test. According to documentation, "if you use a CODE statement, score code is generated and stored in a file that can be used for scoring purposes." I assume I can grab this CODE output and use it on my test data set. I can't seem to find an example thereof, but it is alluded to in Paper SAS474-2017.

 

How would I go about computing my test results?

Stat nation!
1 ACCEPTED SOLUTION

Accepted Solutions
sbxkoenk
SAS Super FREQ

The CODE statement converts the final BNET into SAS DATA step code that can be used for scoring. The code is written to the file that is specified by filename.

It's the body of the data step that is written to the file (no data statement, no set statement and no run statement).

 

Here's an example :

filename abc '/srv/nfs/kubedata/compute-landingzone/SBXKOK/files/hpbnet_my_scorecode.sas'; 

proc hpbnet data=sashelp.Iris numbin=3 structure=Naive maxparents=1
         prescreening=0 varselect=0;
     target Species;
     input PetalWidth PetalLength SepalLength SepalWidth/level=INT;
     output network=network;
     code file=abc;
 run;

data work.new_data_scored;
 set sashelp.iris;
 %INCLUDE abc / source2;
run;
/* end of program */


Ciao,

Koen

View solution in original post

2 REPLIES 2
sbxkoenk
SAS Super FREQ

The CODE statement converts the final BNET into SAS DATA step code that can be used for scoring. The code is written to the file that is specified by filename.

It's the body of the data step that is written to the file (no data statement, no set statement and no run statement).

 

Here's an example :

filename abc '/srv/nfs/kubedata/compute-landingzone/SBXKOK/files/hpbnet_my_scorecode.sas'; 

proc hpbnet data=sashelp.Iris numbin=3 structure=Naive maxparents=1
         prescreening=0 varselect=0;
     target Species;
     input PetalWidth PetalLength SepalLength SepalWidth/level=INT;
     output network=network;
     code file=abc;
 run;

data work.new_data_scored;
 set sashelp.iris;
 %INCLUDE abc / source2;
run;
/* end of program */


Ciao,

Koen

KeanuHua4
Calcite | Level 5

Thanks.

 

Forgot to say I had actually figured this a few days after posting when I realized the code file looks like, well, code. Unfortunately, it's not quite so clear if this is mathematically the same naive Bayes algorithm as GaussianNB in Python (scikit-learn) or naiveBayes in R (e1071), which are what I'm using for class. Doesn't look like I'll be able to use this, but it was a good learning experience at least.

Stat nation!

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

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