Scripts2026年7月4日·1 分钟阅读

LIME — Explain Any Machine Learning Prediction

LIME (Local Interpretable Model-agnostic Explanations) is a Python library that explains predictions of any classifier or regressor by learning an interpretable local model around each prediction.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
LIME Explainer
直接安装命令
npx -y tokrepo@latest install dbb36480-7760-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

LIME is a model-agnostic explanation technique introduced in the 2016 paper "Why Should I Trust You?" by Marco Tulio Ribeiro, Sameer Singh, and Carlos Guestrin. It explains individual predictions by perturbing the input and fitting a simple, interpretable model around the neighborhood of each data point. LIME works with any black-box classifier or regressor.

What LIME Does

  • Explains individual predictions for tabular, text, and image data
  • Generates human-readable feature importance for any model
  • Works with scikit-learn, XGBoost, TensorFlow, PyTorch, and any predict function
  • Highlights which input features drove a specific prediction
  • Supports submodular pick (SP-LIME) for selecting representative explanations

Architecture Overview

LIME perturbs the input around a data point, obtains predictions from the black-box model for each perturbation, and fits a weighted linear model locally. The weights decrease with distance from the original point. For text, it removes words; for images, it masks superpixels; for tabular data, it samples from the training distribution. The resulting sparse linear model coefficients become feature importances.

Self-Hosting & Configuration

  • Install via pip: pip install lime
  • Requires Python 3.6+ with NumPy and scikit-learn
  • No external services or APIs needed
  • Works in Jupyter notebooks with built-in HTML visualizations
  • Configurable: number of features, perturbation count, and kernel width

Key Features

  • Truly model-agnostic: works with any classifier that exposes a predict function
  • Built-in support for tabular, text, and image explanation modes
  • Generates interactive HTML explanations for notebooks
  • SP-LIME picks a diverse set of representative explanations for a dataset
  • Lightweight with minimal dependencies

Comparison with Similar Tools

  • SHAP — provides global and local explanations with Shapley values; LIME is faster for single predictions
  • Captum — PyTorch-specific attribution methods; LIME is framework-agnostic
  • InterpretML — Microsoft's unified interpretability; LIME focuses on local explanations
  • Anchor — by the same authors, provides rule-based explanations with coverage guarantees

FAQ

Q: How is LIME different from SHAP? A: LIME fits a local linear model around each prediction. SHAP computes Shapley values, offering stronger theoretical guarantees but at higher computational cost for some model types.

Q: Can LIME explain deep learning models? A: Yes. As long as the model exposes a prediction function, LIME can explain it regardless of architecture.

Q: Is LIME suitable for production use? A: LIME is commonly used in production for model auditing and compliance. Explanation latency depends on the number of perturbations configured.

Q: Does LIME support regression? A: Yes. Use LimeTabularExplainer with mode set to regression.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产