If I trained a network using Neural Network classifier, how can I know which feature was most important for predicting the target variable? I mean how to create a "feature ranking" among the features (from high importance value to low). I have seen some literature about decision trees/AdaBoost but I am typically interested in Neural networks especially for classification purpose. To make it more clear, an example is shown in the figure.
The firs solution sevo proposes is not feasible because of a third problem that was not mentioned. The first layer only learns a first representation of the input, which is used in later layers. Even if the absolute weights of $x_1$ might be very big, if the later layers have small weights connected to these neurons the importance goes down. This is exactly why neural networks are considered to be difficult to interpret. The rest of the answer is useful, I just wanted to add this.
There are multiple possibilities.
The obvious one is to sum weights of all connections from input layer to the first hidden layer per input neuron. The neuron with highest sum of connection weights should be the most important. This has several problems.
- Weights could be negative so you should use absolute value of them.
- The weight depend on the scale of the input variable. You should normalize the input for example by subtracting mean and dividing by standard deviation of the input (z-normalization).
Another possibility is to selectively remove features, retrain the network and observe removal of which features caused the biggest decrease in model accuracy. These are potentially the most important features.
The problem of this approach is, that it changes the architecture of the network, retrains it and does not report the relevance of features entering the original network.
You can find an elaborate discussion on the problem here ftp://ftp.sas.com/pub/neural/importance.html
There are multiple other approaches, such as Garson's, using complex functions to correct for some problems. You can find several of them implemented in NeuralNetTools package in R.