BookmarkSubscribeRSS Feed
rboire
Calcite | Level 5

have attempted to determine variable contributions by using the weights of each variable which are located in the input layer. See attached output file from PROC HPNEURAL where the output file occurs from the OUTMODEL statement .You will note that I use only the weights reported in the input layer because each input layer is connected to all the hidden layers. So the real differentiator are the weights of the variables in the input layer.  You will see that the highlighted section(in green) represents the information which I  would use to calculate a given variable's contribution (i.e. sum up all the node weights(absolute) for that variable and then divide by the total weights of all nodes and all variables) but for the input layer only. Do not need to worry about the hidden layers as all the hidden layers and their weights map back to each node in the input layer. see attached file.

6 REPLIES 6
AnnaBrown
Community Manager

Hi @rboire,

 

Can you clarify your question here? The community may be able to assist if you provide more details and a more defined question. I see this other related thread between you and @DougWielenga: SAS Code for variable importance in neural net, so I'll include it here for reference.

 

Thanks!

Anna  

rboire
Calcite | Level 5

Hi Anna,

 

I am not sure of the specific details you need. I have attached output and an explanation of the real issue which is trying to use the weights in the neural net as a way of capturing the variable importance. Again, though, thanks for your reply.

AnnaBrown
Community Manager

Thanks @rboire. I'll pass this along to some SAS experts here and see if they can assist or if more clarification is needed.

 

Anna

WendyCzika
SAS Employee

Do you have a reference about calculating variable importance/contribution based on the weights in this manner?  This is not something we generally advise, as you can have completely different sets of weights producing the same model and other issues with this approach are discussed here: ftp://ftp.sas.com/pub/neural/importance.html

BrettWujek
SAS Employee

Using the weights in a neural network to determine variable importance is not straightforward (and some would argue can't/shouldn't be done), and if you are not careful you can easily end up with very misleading results. A weight from a node in the input layer (ie, representing that input) to a given node in the first hidden layer is not representative of the impact of that input on the final output node since it is only one small contribution to a very complex mathematical function combining all activation functions from other nodes in that layer, nested within the activation functions of subsequent layers.  The only real way to follow this through is with a very complicated application of the chain rule combining sensitivity information from the output node back to the input, through all layers and all nodes in those layers.

 

My suggestion would be to build a surrogate decision tree model using scored output values from your NN model.  That is, score the training data set using the NN so that you now have a y_scored column and train a decision tree on all inputs vs y_scored.  The decision tree will give you a good assessment of variable importance.


Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF

View now: on-demand content for SAS users

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
  • 6 replies
  • 2575 views
  • 0 likes
  • 4 in conversation