Skip to main content

The SLISE algorithm for robust regression and explanations of black box models

Project description

PySLISE Banner Image
PyPI Documentation Tests License: MIT Binder

SLISE - Sparse Linear Subset Explanations

Python implementation of the SLISE algorithm. The SLISE algorithm can be used for both robust regression and to explain outcomes from black box models. For more details see the conference paper, the robust regression paper, or the local explanation paper. Alternatively for a more informal overview see the presentation, or the poster. Finally, for learning to use the python package there are several examples and the documentation.

Björklund A., Henelius A., Oikarinen E., Kallonen K., Puolamäki K. (2019)
Sparse Robust Regression for Explaining Classifiers.
Discovery Science (DS 2019).
Lecture Notes in Computer Science, vol 11828, Springer.
https://doi.org/10.1007/978-3-030-33778-0_27

Björklund A., Henelius A., Oikarinen E., Kallonen K., Puolamäki K. (2022).
Robust regression via error tolerance.
Data Mining and Knowledge Discovery.
https://doi.org/10.1007/s10618-022-00819-2

Björklund A., Henelius A., Oikarinen E., Kallonen K., Puolamäki K. (2023)
Explaining any black box model using real data.
Frontiers in Computer Science 5:1143904.
https://doi.org/10.3389/fcomp.2023.1143904

The idea

In robust regression we fit regression models that can handle data that contains outliers (see the example below for why outliers are problematic for normal regression). SLISE accomplishes this by fitting a model such that the largest possible subset of the data items have an error less than a given value. All items with an error larger than that are considered potential outliers and do not affect the resulting model.

SLISE can also be used to provide local model-agnostic explanations for outcomes from black box models. To do this we replace the ground truth response vector with the predictions from the complex model. Furthermore, we force the model to fit a selected item (making the explanation local). This gives us a local approximation of the complex model with a simpler linear model (this is similar to, e.g., LIME and SHAP). In contrast to other methods SLISE creates explanations using real data (not some discretised and randomly sampled data) so we can be sure that all inputs are valid (i.e. in the correct data manifold, and follows the constraints used to generate the data, e.g., the laws of physics).

Installation

To install this package just run:

pip install slise

Or install the latest version directly from GitHub:

pip install git+https://github.com/edahelsinki/pyslise

Alternatively you can download the repo and run python -m build to build a wheel, or pip install . to install it locally.

Numba

SLISE uses Numba to speed up the calculations. You might want to install the optional libraries to get the most out of Numba:

pip install "slise[tbb]"

Other implementations

The (original) R implementation can be found here.

Examples

Here are two quick examples of SLISE in action. For more detailed examples, with descriptions on how to create and interpret them, see the examples directory.

Example of Robust Regression
SLISE is a robust regression algorithm, which means that it is able to handle outliers. This is in contrast to, e.g., ordinary least-squares regression, which gives skewed results when outliers are present.

 

Example of Explanation
SLISE can also be used to explain outcomes from black box models by locally approximating the complex models with a simpler linear model.

Dependencies

This implementation requires Python 3 and the following packages:

  • matplotlib
  • numba
  • numpy
  • PyLBFGS
  • scipy

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

slise-2.2.4.tar.gz (32.3 kB view details)

Uploaded Source

Built Distribution

slise-2.2.4-py3-none-any.whl (29.7 kB view details)

Uploaded Python 3

File details

Details for the file slise-2.2.4.tar.gz.

File metadata

  • Download URL: slise-2.2.4.tar.gz
  • Upload date:
  • Size: 32.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for slise-2.2.4.tar.gz
Algorithm Hash digest
SHA256 c6dbece99029f6ead584aa985b7730f2142e9e3ea93ea1311922d0fa1a8c4b96
MD5 5ab54c71743e3b7d8d13246dc7c7870e
BLAKE2b-256 0daed377c8cf8a3ba04ec717b56136f65290c73ba1ba2d91e117b6a321e51917

See more details on using hashes here.

File details

Details for the file slise-2.2.4-py3-none-any.whl.

File metadata

  • Download URL: slise-2.2.4-py3-none-any.whl
  • Upload date:
  • Size: 29.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for slise-2.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2b42ff82a997148db192ee448b3a377487fefd1dcb326cef1fa9e0784d47da13
MD5 632de4929d9c55d16cd9b56667d3cddd
BLAKE2b-256 ad0c3dd6ce6a2316e0ad4cf797f21ccefcfb83dec84c78b9e44e115be6b33c81

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page