Inferensys

Glossary

Feature Importance

A numerical score assigned to each input feature by a local surrogate model, indicating the magnitude and direction of that feature's contribution to the specific prediction being explained.
Data engineer managing feature store on laptop, feature definitions visible, casual data engineering session.
LOCAL SURROGATE ATTRIBUTION

What is Feature Importance?

Feature importance, within the context of Local Interpretable Model-agnostic Explanations (LIME), is a numerical score quantifying each input feature's contribution to a specific, individual prediction made by a black-box model.

Feature importance is a numerical score assigned to each input feature by a local surrogate model, indicating the magnitude and direction of that feature's contribution to a specific prediction. In LIME, these scores are the coefficients of a sparse linear model trained on perturbed samples, revealing which features most strongly pushed the black-box model toward its decision for a single instance.

The scores provide an additive feature attribution explanation, decomposing the prediction into a sum of individual feature contributions. A high positive importance for a word in a text classifier, for example, indicates strong evidence for the predicted class, while a negative score indicates evidence against it. This local, instance-level explanation contrasts with global feature importance, which describes average model behavior across an entire dataset.

LOCAL ATTRIBUTION MECHANICS

Key Characteristics of LIME Feature Importance

Feature importance in LIME is a numerical score assigned by the local surrogate model, quantifying each feature's contribution to a specific prediction. These scores are the core output that makes black-box decisions auditable.

01

Additive Contribution Decomposition

LIME decomposes a single prediction into a sum of individual feature contributions plus a base intercept. The feature importance score represents the additive effect of that feature on the prediction.

  • Linear surrogate: For a linear model, the coefficient for feature x_i multiplied by its value is its contribution.
  • Summation property: Prediction = Intercept + Σ(Feature_i_Contribution).
  • Directionality: A positive score pushes the prediction toward a specific class; a negative score pushes it away.
  • Magnitude: The absolute value indicates the strength of the influence, not just the presence of the feature.
02

Local Scope and Context Dependency

Feature importance scores are strictly local—they explain only the specific instance being analyzed, not the model's global behavior. The same feature can have drastically different importance for different predictions.

  • Instance-specific: An importance score is valid only in the immediate neighborhood of the explained data point.
  • Decision boundary curvature: In highly non-linear regions, a feature might be critical for one prediction and irrelevant for a nearby one.
  • Contrast with global methods: Unlike a single global feature importance ranking, LIME reveals that a model uses different reasoning paths for different inputs.
  • Temporal stability: For the same instance, importance scores should remain stable across multiple runs with different random seeds.
03

Sparsity via L1 Regularization

To ensure human readability, LIME often employs Lasso (L1) regularization when training the surrogate linear model. This forces the coefficients of less important features to exactly zero.

  • Concise explanations: Only the top K features with non-zero coefficients are presented, where K is a user-defined budget.
  • Feature selection: L1 penalty performs automatic feature selection during surrogate training, eliminating noise.
  • Trade-off: Higher regularization increases sparsity but may reduce local fidelity.
  • Interpretable representation: The non-zero features are drawn from the interpretable representation (e.g., presence of a word, a superpixel), not raw pixels or token IDs.
04

Weighted by Proximity

The importance scores are derived from a locally weighted regression where perturbed samples closer to the original instance have higher influence on the surrogate model's fit.

  • Exponential kernel: Sample weights decay exponentially with distance: weight = exp(-distance / kernel_width).
  • Kernel width: This hyperparameter defines the effective neighborhood size. A small width enforces strict locality; a large width smooths the explanation.
  • Distance metric: Varies by data type—cosine distance for text (TF-IDF vectors), Euclidean distance for tabular data, and superpixel overlap for images.
  • Impact on importance: Features that are consistently predictive in the immediate vicinity receive high importance scores.
05

Fidelity-Interpretability Trade-off

The feature importance scores reflect a fundamental compromise: a simple linear model may not perfectly capture the local decision boundary, leading to some loss of local fidelity.

  • Fidelity measure: The R-squared score of the surrogate model on the perturbed samples indicates how well the importance scores represent the black-box behavior.
  • Interpretability constraint: A linear model with sparse features is highly interpretable but may miss complex local interactions.
  • Diagnostic tool: Low fidelity warns that the importance scores should be treated as an approximation, not a precise decomposition.
  • OptiLIME: An automated method that selects the kernel width to balance fidelity and stability, ensuring the importance scores are both accurate and reproducible.
06

Visualization as Saliency Maps

For image data, feature importance scores are visualized as saliency masks—heatmaps that highlight which superpixels contributed most to the prediction.

  • Superpixel granularity: Importance is assigned to perceptually grouped pixel regions, not individual pixels, making the explanation semantically meaningful.
  • Positive vs. negative evidence: Green regions indicate features supporting the predicted class; red regions indicate features contradicting it.
  • Human validation: A domain expert can visually inspect the mask to verify if the model is focusing on clinically or operationally relevant regions.
  • Explanation pipeline: The raw importance scores are mapped back to the original image coordinates to generate the final overlay.
FEATURE IMPORTANCE IN LIME

Frequently Asked Questions

Clear answers to common questions about how LIME assigns numerical scores to input features, indicating their contribution to a specific prediction.

Feature importance in LIME is a numerical score assigned to each input feature by the local surrogate model, quantifying the magnitude and direction of that feature's contribution to the specific prediction being explained. These scores are the coefficients of the sparse linear model trained on perturbed samples. A positive score indicates the feature pushed the prediction toward a particular class, while a negative score indicates it pushed away. The absolute value represents the strength of the influence. Because LIME uses an interpretable representation—such as the presence or absence of words for text or superpixels for images—the importance is assigned to these human-understandable components, not raw pixels or token IDs. This allows a practitioner to state, for example, that the word 'excellent' contributed +0.35 to a positive sentiment classification, while 'slow shipping' contributed -0.42.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.