Explainable Multilayer Perceptron

Machine Learning
Introduced by
Lundberg & Lee (SHAP); Ribeiro et al. (LIME); broader XAI community
Year
2010s–present
Type
Supervised feedforward neural network with interpretability layer
Family
Deep learning / NLP / CV

What does it do?

An Explainable Multilayer Perceptron (XMLP) is a feedforward neural network trained with backpropagation, with a post-hoc explanation step (such as SHAP values, LIME or integrated gradients) that attributes each prediction to individual input features.

The explanation is computed after training and approximates the trained model's behaviour; it does not make the network itself transparent. The approach is used when a nonlinear model is needed and feature-level justification of individual predictions is also required.

The intuition behind the method

A plain MLP computes its output by chaining weighted sums and nonlinear activations across layers, which makes an accurate prediction hard to trace back to individual inputs. Post-hoc methods treat the trained network as a black box and measure how the output changes when each input feature is varied or removed. SHAP, for example, takes its attributions from Shapley values in cooperative game theory, so the per-feature contributions for one prediction add up to the difference between that prediction and a baseline value. The result is a signed, per-case list of feature contributions that stakeholders can inspect alongside the prediction.

History

Multilayer perceptrons trained by backpropagation are a long-established neural network design. Interest in explaining such networks grew during the 2010s, as machine learning was applied to decisions that affect people and regulated domains increasingly asked for justification of automated decisions. Local surrogate methods such as LIME and gradient-based methods such as integrated gradients were developed in the same period. SHAP (Lundberg & Lee, 2017) provided a unified attribution framework based on Shapley values, and it is the attribution basis used on this page.

When to use it

Choose an Explainable MLP when a nonlinear neural model is needed and individual predictions must be justified to regulators, clinicians or other stakeholders, as in credit scoring, medical decision support or policy modelling. It fits tabular data with a moderate number of features (typically tens to hundreds) and a labelled sample large enough to support separate training, validation and test sets. Prefer it over a plain MLP when feature-level transparency is required, not merely desirable. Do not use it for image or text data: this architecture is a fully connected network over feature vectors, and the explanation tools suited to those data are the saliency or attention-based methods associated with convolutional and transformer models. Also avoid it when an inherently interpretable model such as logistic regression or a decision tree reaches acceptable accuracy, because the network plus explanation pipeline adds debugging and maintenance work.

Limitations and considerations

  • Post-hoc explanations approximate what the network computes; they do not reveal the mechanism behind a prediction, and a large attribution is a statistical association within this model.
  • Exact Shapley computation is costly as the number of features grows, and TreeSHAP does not apply to a neural network, so practitioners rely on approximations such as KernelSHAP or DeepSHAP, whose accuracy has to be checked.
  • Explanations can be unstable: nearly identical inputs can receive noticeably different attributions, so per-case explanations need stability checks.
  • The explanation layer does not constrain the MLP's internal representations, so the network can still learn spurious correlations, and the attributions may faithfully report them.
  • SHAP and gradient-based attributions depend on the chosen reference or background data, and a poor baseline distorts the attributions.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Keeps the nonlinear function class of an MLP while adding feature-level attributions, which is the main reason to choose it over a plain MLP when individual predictions must be justified.
  • SHAP attributions satisfy an efficiency (additivity) property: for each prediction they sum to the difference between the model output and its expected output, so the explanation accounts for the whole deviation from the baseline.
  • The explanation step is modular: SHAP, LIME or integrated gradients can be applied to the same trained network, and the attribution method can be changed without retraining the model.
  • SHAP provides both per-prediction attributions and a global ranking obtained by aggregating them across cases.
  • Applies to classification and regression on tabular inputs with the same training and attribution workflow.
  • Open-source implementations of SHAP and LIME make the attribution step straightforward to add to an existing pipeline.

Applications

  • Credit risk scoring and loan-approval systems requiring regulatory explanation of each decision.
  • Clinical decision support where clinicians need feature-level justification for a diagnosis or triage recommendation.
  • Fraud detection dashboards that show analysts which transaction features triggered an alert.
  • Educational assessment models predicting student outcomes, with attribution reports for academic advisors.
  • Industrial predictive maintenance, identifying which sensor signals contributed most to a predicted failure.
  • Policy modelling in social science research where causal plausibility of predictors must be assessed.

How it works

How it works

1

Define a feedforward network with one or more hidden layers, choosing the activation functions (ReLU, tanh or sigmoid) and the number of neurons per layer. For tabular data, a common starting point is two hidden layers of 64–256 neurons each, with depth and width tuned by a hyperparameter search on the validation set. The output layer uses softmax for classification and a linear activation for regression. Before training, standardise numeric inputs using the mean and standard deviation of the training set only, and encode categorical features (for example as one-hot vectors) so that the network receives a numeric feature vector. Applying the same transformations to the validation and test data avoids information leakage.

2

Train with stochastic gradient descent or Adam to minimise the average task loss over the training set (cross-entropy for classification, MSE for regression). Regularisation such as dropout or L2 weight decay limits overfitting. When classes are imbalanced, apply class weights in the loss or resample the training set only, leaving the validation and test sets with their natural class distribution. A validation set is used for early stopping, and performance is reported on a separate test set that played no part in model selection.

Formula
\mathcal{L} = \frac{1}{n}\sum_{i=1}^{n}\ell(f(x_i; \theta), y_i)
3

After training, apply a post-hoc method. SHAP computes Shapley values, which distribute each prediction's deviation from a baseline across the input features by averaging each feature's marginal contribution over subsets of the other features. The background data that defines the baseline should be a representative subsample of the training set, sized so that the computation remains tractable, because the choice of background changes the attributions. LIME fits a local linear surrogate around each prediction. Integrated gradients accumulate gradients along an interpolation path from a reference input to the actual input.

Formula
\phi_j = \sum_{S \subseteq F \setminus \{j\}} \frac{|S|!(|F|-|S|-1)!}{|F|!}[f(S \cup \{j\}) - f(S)]
4

Aggregate per-instance attributions into a global feature ranking, for example by mean absolute SHAP value. Bar charts, beeswarm plots or force plots display the attributions. For a single prediction, the signed attribution shows whether a feature pushed the output up or down and by how much.

5

Check whether the top-ranked features are plausible for the domain, confirm that attributions are reproducible by fixing random seeds and the background set, and measure faithfulness with metrics such as sufficiency and comprehensiveness. Report the model's accuracy alongside the explanation results, because attributions from an inaccurate model say little about the problem.

Common pitfalls

  • Reporting attributions before confirming the model's accuracy on held-out data; attributions from a poorly fitting network describe the network rather than the problem.
  • Reading SHAP values as causal effects: a large attribution shows that a feature contributes to the model's output, not that changing the feature would change the real-world outcome.
  • Running KernelSHAP on a large feature set without subsampling the background data or features, which makes runtime prohibitive and results approximate.
  • Skipping consistency checks: attributions from sampling-based approximations such as KernelSHAP can vary between runs unless random seeds and the background set are fixed. Dropout must be disabled at inference so that the network being explained is the one used for prediction.
  • Showing only the global feature ranking while ignoring how much attributions vary across cases, which can overstate how reliable the explanation is for a particular individual.

Frequently asked questions

Is an Explainable MLP the same as an inherently interpretable model?

No. An inherently interpretable model, such as logistic regression or a decision tree, is transparent by design. An Explainable MLP is a black-box network with a post-hoc explanation step added after training. Post-hoc attributions approximate the model's behaviour and do not constrain it, so they can be incorrect or unstable.

Which explainability method should I choose — SHAP, LIME, or integrated gradients?

SHAP is usually the most principled choice for tabular data, because Shapley values satisfy the axioms of efficiency, symmetry, dummy and linearity. LIME is quicker for local checks, and integrated gradients suit differentiable models when gradient-based attribution is preferred to sampling. The Shapley axioms apply to each prediction, so they do not by themselves guarantee that explanations agree across different models.

How many hidden layers and neurons are appropriate?

For tabular data with dozens to a few hundred features, two hidden layers of 64–256 neurons each is a common starting point. Increase capacity if validation loss plateaus early, and reduce it if the gap between training and validation loss is large. A hyperparameter search, by grid or Bayesian methods, is recommended.

Does adding explainability reduce model accuracy?

Post-hoc methods such as SHAP and LIME do not modify the trained network, so they do not change its accuracy. Constraining the architecture or loss for inherent interpretability, for example with monotone networks, may involve an accuracy trade-off.

How do I validate that the explanations are trustworthy?

Run faithfulness tests: remove the top-k features ranked by SHAP, replacing them with baseline values, and measure the drop in model output. Separately, keep only the top-k features and measure how much of the model output they retain. Check stability by adding small Gaussian noise to inputs and confirming that attribution rankings stay similar. Also check that the top features agree with domain knowledge.

Related methods

Sources

  1. Lundberg, S. M., & Lee, S.-I. (2017). A unified approach to interpreting model predictions. Advances in Neural Information Processing Systems, 30, 4765–4774.

    Open publication reference
  2. Explainable artificial intelligence. Wikipedia.

    Open publication reference