Model-agnostic explanation

Also known as: model-agnostic interpretability

On this page 7

A model-agnostic explanation is an interpretation of a machine learning model that is produced only from its inputs and outputs, treating the model as a black box whose internal structure, weights and gradients are not used. In Explainable AI, this family of methods, also called model-agnostic interpretability, can be applied in the same way to a gradient-boosted ensemble, a neural network or a proprietary scoring service reachable only through an API.

The central idea is systematic perturbation: the method changes input values, queries the model, and infers from the resulting predictions which features matter and how. The price of this flexibility is computational cost and a dependence on assumptions about how perturbed inputs should be generated.

How model-agnostic methods probe a black box

Every model-agnostic method follows the same loop: create variations of inputs, obtain predictions for them, and summarize the relationship between variations and predictions. The methods differ in how they generate variations and in what summary they report.

Some methods fit an interpretable surrogate, such as a sparse linear model or a shallow tree, to mimic the black box locally or globally. Others compute attribution scores grounded in cooperative game theory, and others visualize marginal effects by plotting predictions as one feature varies. All of them need only a prediction function, which is why they are attractive for audits of third-party systems.

MethodScopeOutput
LIMELocalWeights of a sparse linear surrogate
KernelSHAPLocal, aggregable to globalShapley value per feature
Permutation feature importanceGlobalDrop in performance per feature
Partial dependence plotGlobalAverage prediction curve
Individual conditional expectation plotLocalOne curve per instance
AnchorsLocalIf-then rule with coverage and precision
Counterfactual explanationLocalMinimal input change that alters the outcome
Main families of model-agnostic explanation methods

Model-agnostic versus model-specific explanation

Model-agnostic explanation differs from model-specific explanation in what it is allowed to see. Model-specific methods such as TreeSHAP, Grad-CAM++ or layer-wise relevance propagation read the internal structure of one model class, which makes them faster and often more exact, but they cannot be transferred to another architecture.

CriterionModel-agnosticModel-specific
Required accessPrediction function onlyWeights, gradients or tree structure
PortabilityAny model classOne architecture family
Computational costHigh, many model queriesLow to moderate
ExactnessApproximate, sampling-basedOften exact for the model class
Comparing different modelsSame method across modelsMethods differ by model
Trade-offs between the two approaches

In practice, the portability advantage is decisive in model selection and governance. A team comparing a logistic regression, a random forest and a neural network can apply one method to all three and compare explanations on equal terms, which supports consistent documentation in model cards and audit reports.

Choosing a model-agnostic method

The right method depends on the question being asked and on the audience. A regulator asking why one application was rejected needs a local explanation, while a data scientist checking whether a model relies on a leaked feature needs a global one.

QuestionSuitable methodReason
Which features drive this single predictionKernelSHAP or LIMEPer-instance attribution
Which features matter overallPermutation importanceMeasures performance dependence
How does the prediction change with one featurePartial dependence or ALE plotShows the shape of the effect
What must change to get a different decisionCounterfactual explanationActionable recourse for users
Do features interact stronglyFriedman’s H-statisticQuantifies interaction strength
Decision guide for common explanation questions

When features are strongly correlated, accumulated local effects are usually preferred over partial dependence plots, because partial dependence averages over unrealistic combinations of feature values.

Faithfulness, stability and other limitations

The main limitation of model-agnostic explanation is that it reports a simplified view of the model, and the simplification can be wrong. Explanation faithfulness, the degree to which an explanation reflects the true reasoning of the model, is never guaranteed and must be tested.

  • Off-manifold sampling: perturbations create unrealistic inputs, so the model is explained in regions it never saw.
  • Instability: LIME and sampled SHAP can give different attributions on repeated runs.
  • Correlated features: credit is split arbitrarily among features that carry the same information.
  • Manipulation risk: a model can be built to behave differently on perturbed inputs and hide bias from the explainer.
  • Rashomon effect: many equally accurate models exist, each with a different valid explanation.

Good practice is to compare several methods, fix random seeds, report variance across runs and validate explanations with deletion or insertion tests, which measure how quickly predictions change when the most important features are removed.

Tools and regulatory relevance

Model-agnostic methods are implemented in widely used open-source libraries, including the SHAP and LIME packages, InterpretML, AI Explainability 360 and Captum, and they appear in the explanation features of major cloud ML platforms. The What-If Tool offers interactive counterfactual exploration for tabular models.

Their regulatory importance is growing because many systems that need justification are opaque by design. Credit adverse action notices, transparency duties for high-risk systems under the EU AI Act and internal model risk management policies all require explanations that a reviewer can apply across vendors and model types, which model-agnostic methods make feasible.

Because every method works through repeated queries, query budget planning is part of any deployment. The cost grows with the number of explained instances, the number of features and the size of the background sample, and it matters most when each call to a hosted model is billed or rate-limited.

MethodQueries per explained instanceMain cost driver
LIMEHundreds to a few thousandNumber of perturbation samples
KernelSHAPThousands, often moreCoalitions times background sample size
Permutation importanceNot per instance; features times repeats times dataset sizeRepetitions per feature
Partial dependence plotGrid points times dataset sizeGrid resolution
Counterfactual searchHundreds to thousandsSearch algorithm and constraints
Approximate query cost of common methods

Teams reduce this burden by caching predictions, summarizing the background data with k-means centroids and explaining a stratified sample of instances instead of the full population. These shortcuts trade some precision for feasibility, so the sampling settings should be reported together with the explanation itself.

In plain words

Some models are too complex to read from the inside. A model-agnostic explanation does not try. It asks the model many small questions instead.

It is like testing a recipe without seeing it. You change one ingredient at a time and taste the result. Soon you learn which ingredients matter most. The method works on any model, but the answer is an estimate, not a full view of the inner workings.

A real-world example

A mid-sized insurer buys a claims fraud model from an external vendor and receives only a scoring API. The compliance team must explain to auditors why claims are flagged, and the vendor does not disclose the model structure.

Analysts run KernelSHAP on 2,000 recent claims with a background sample of 200 typical claims, which requires roughly two million API calls processed over a weekend. Aggregated attributions show that claim amount, time since policy start and repair shop identity dominate the scores. They also reveal that postal code carries unexpectedly high weight, which acts as a proxy for neighborhood income.

The insurer confirms the finding with permutation importance and a counterfactual test, then asks the vendor to retrain without location features. The outcome is a documented, auditable explanation produced without any access to the internals of the model.