BookmarkSubscribeRSS Feed
quigleym
Fluorite | Level 6

Hi:

 I have weights that range in value from 0 to 1 (for example .05). I am able to run a weighted logistic regression using

 

proc logistic data = logistic outmodel=log_model;
  model  target_good_final (event='1') = &keep_it2  / selection = forward sle=.01;
  output out = stats p = prob_good_log xbeta = logit_good ;
  weight weight;

 

But I am not sure how to do the same thing for a neural net work. There doesn't appear to be a weight statement for Proc Neural,

Proc DMNEURL suggest that you use include the weight variable in your data set as a "Freq" variable. Then use Proc DMDB to create a catalog for its use. But if you make weight a FREQ variable then it becomes an integer which I don't want . PROC IMSTAT has a Neural statement and a weight that does not require a PROC DMDB as required by Proc Neural and Proc DMNEURL (See below).

 

  proc dmdb data=training&j dmdbcat=cat;
   class ⌖
   var &inputs;  
   target ⌖

 

Any suggestions as the best way to go ?

 

                                       Thanks

 

                                             Michael Quigley

2 REPLIES 2
MikeStockstill
SAS Employee

Consider using PROC HPNEURAL instead of PROC NEURAL.  PROC HPNEURAL has a WEIGHT statement.  Here is an excerpt:

 

 

WEIGHT Statement
WEIGHT variable | _INVERSE_PRIORS_ ;
If you specify a WEIGHT statement, variable identifies a numeric variable in the input data set that contains
the weight to be placed on the prediction error (the difference between the output of the network and the
target value specified in the input data set) for each observation during training.
If, instead of specifying a variable, you specify the keyword _INVERSE_PRIORS_, the HPNEURAL
procedure calculates the weight applied to the prediction error of each nominal target variable as the total
number of observations divided by the number of observations whose target class is the same as the current
observation (in other words, the inverse of the fraction of the number of times that the target class occurs in
the input data set).
If variable is less than or equal to 0 or is missing, the observation is not used for training or for computing
validation error. When validation error is computed during training, the weights on the validation observations
are used even though weights are not used when scoring.
The WEIGHT statement is optional. If a WEIGHT statement is not included, all observations are assigned a
weight of 1.

 

For full documentation, go to http://support.sas.com/documentation/onlinedoc/miner/index.html, and select 

 

Have a great new year.

quigleym
Fluorite | Level 6

Great Idea this worked. I tried a number of different results some examples are shown below:

 

First: One layer 2 neurons:

proc hpneural data=tempq;

   input &keep_it;

   id perf_seq_num &target &validate &weight ;

   target &target / level=nom;

   hidden 2;

  partition rolevar=&validate(train=0);

   train outmodel=model_l1_n2 numtries=5 maxiter=1000;

   scores out=scores_l1_n2;

   code file = "&codefile";

   weight &weight;

 

run;

 

Second: 2 Layers 3 Neurons:

 

proc hpneural data=tempq;

   input &keep_it;

   id perf_seq_num &target &validate &weight ;

   target &target / level=nom;

   hidden 3;

   hidden 3;

  partition rolevar=&validate(train=0);

   train outmodel=model_&model numtries=5 maxiter=1000;

   score out=scores_&model;

   code file = "&codefile";

   weight &weight;

 

run;

 

Third: 5 layers 3 Neurons:

 

proc hpneural data=tempq;

   input &keep_it;

   id perf_seq_num &target &validate &weight ;

   target &target / level=nom;

   hidden 3;

   hidden 3;

   hidden 3;

   hidden 3;

   hidden 3;

  partition rolevar=&validate(train=0);

   train outmodel=model_&model numtries=5 maxiter=1000;

   score out=scores_&model;

   code file = "&codefile";

   weight &weight;

 

 

 

 

 

 

Fourth: 2 Layers First layer 100 neurons Second layer 50 neurons:

 

proc hpneural data=tempq;

   input &keep_it;

   id perf_seq_num &target &validate &weight ;

   target &target / level=nom;

   hidden 100;

   hidden 50;

  partition rolevar=&validate(train=0);

   train outmodel=model_&model numtries=5 maxiter=1000;

   score out=scores_&model;

   code file = "&codefile";

   weight &weight;

 

run;

 

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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