Git Product home page Git Product logo

edahelsinki / pyslise Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 1.0 3.63 MB

Robust regression algorithm that can be used for explaining black box models (Python implementation)

Home Page: https://edahelsinki.fi/pyslise/

License: MIT License

Python 100.00%
python robust-regression black-box-explanations local-explanations explain-classifiers explainable-ai explainable-ml interpretable-machine-learning sparse-regression model-agnostic machine-learning research-paper research slise slise-algorithm

pyslise's Introduction

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

pyslise's People

Contributors

aggrathon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

vishalbelsare

pyslise's Issues

plot_dist() for many input features requires massive plot - please add limit for N most important features

Hi,

I'm currently testing out pyslise for a model with many input features (>1000). When using plot_dist() to view the explanation for a given test case, it attempts to plot every feature, which requires making a massive figure in order resolve each feature in the plots. It's generally unwieldy to work with, and presumably not what the devs intended.

Given that the features are already plotted in order of importance, I would suggest adding an option to this function that limits the plot to the N most important features, or better yet, pass in an array of indices that the user wants to plot. This way, one could break up a problem with 1000 inputs into 40 groups of 25 or something more manageable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.