Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
L

lime

> 编程语言
Open source

Lime: Explaining the predictions of any machine learning classifier

12.2K stars0 likes3 views
WebsiteGitHub

About

Lime: Explaining the predictions of any machine learning classifier

lime

This project is about explaining what machine learning classifiers (or models) are doing. At the moment, we support explaining individual predictions for text classifiers or classifiers that act on tables (numpy arrays of numerical or categorical data) or images, with a package called lime (short for local interpretable model-agnostic explanations). Lime is based on the work presented in this paper (bibtex here for citation). Here is a link to the promo video:

Our plan is to add more packages that help users understand and interact meaningfully with machine learning.

Lime is able to explain any black box classifier, with two or more classes. All we require is that the classifier implements a function that takes in raw text or a numpy array and outputs a probability for each class. Support for scikit-learn classifiers is built-in.

Installation

The lime package is on PyPI. Simply run:

bash
pip install lime

Or clone the repository and run:

bash
pip install .

We dropped python2 support in 0.2.0, 0.1.1.37 was the last version before that.

Screenshots

Below are some screenshots of lime explanations. These are generated in html, and can be easily produced and embedded in ipython notebooks. We also support visualizations using matplotlib, although they don't look as nice as these ones.

Two class case, text

Negative (blue) words indicate atheism, while positive (orange) words indicate christian. The way to interpret the weights by applying them to the prediction probabilities. For example, if we remove the words Host and NNTP from the document, we expect the classifier to predict atheism with probability 0.58 - 0.14 - 0.11 = 0.31.

Multiclass case

Tabular data

Images (explaining prediction of 'Cat' in pros and cons)

Tutorials and API

For example usage for text classifiers, take a look at the following two tutorials (generated from ipython notebooks):

  • Basic usage, two class. We explain random forest classifiers.
  • Multiclass case

For classifiers that use numerical or categorical data, take a look at the following tutorial (this is newer, so please let me know if you find something wrong):

  • Tabular data
  • Tabular data with H2O models
  • Latin Hypercube Sampling

For image classifiers:

  • Images - basic
  • Images - Faces
  • Images with Keras
  • MNIST with random forests
  • Images with PyTorch

For regression:

  • Simple regression

Submodular Pick:

  • Submodular Pick

The raw (non-html) notebooks for these tutorials are available here.

The API reference is available here.

What are explanations?

Intuitively, an explanation is a local linear approximation of the model's behaviour. While the model may be very complex globally, it is easier to approximate it around the vicinity of a particular instance. While treating the model as a black box, we perturb the instance we want to explain and learn a sparse linear model around it, as an explanation. The figure below illustrates the intuition for this procedure. The model's decision function is represented by the blue/pink background, and is clearly nonlinear. The bright red cross is the instance being explained (let's call it X). We sample instances around X, and weight them according to their proximity to X (weight here is indicated by size). We then learn a linear model (dashed line) that approximates the model well in the vicinity of X, but not necessarily globally. For more information, read our paper, or take a look at this blog post.

Contributing

Please read this.

Issues· 133 open

View all issuesOpen on GitHub
  • #700

    Deprecation Warning for Ipython

    Updated Jul 9, 2026
  • #768

    Feature request - please expose package version via lime.__version__

    Updated Jul 9, 2026
  • #760

    Hello, is anyone here?

    Updated Jul 9, 2026
  • #767

    LimeTabularExplainer gives completely different explanations every time you run it on the same instance — no random_state fix works reliably

    Updated Mar 25, 2026
  • #765

    LIME for multiclass does not seem to work

    Updated Oct 28, 2025
  • #764

    How do you handle disagreement between LIME, SHAP, and other XAI methods?

    Updated Oct 22, 2025
  • #730

    Can LIME only be used for text classification tasks?

    Updated Sep 24, 2025
  • #762

    Asking for information

    Updated Aug 11, 2025
  • #749

    update Python support

    Updated Apr 17, 2025
  • #757

    project planning

    Updated Mar 9, 2025

> Tags

JavaScript

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 28, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言