Skip to main content

mldissect - model agnostic explanations

Project description

mldissect

https://travis-ci.com/ml-libs/mldissect.svg?branch=master https://codecov.io/gh/ml-libs/mldissect/branch/master/graph/badge.svg Maintainability

mldissect is model agnostic predictions explainer, library can show contribution of each feature of your prediction value.

Features

  • Supports predictions explanations for classification and regression

  • Easy to use API.

  • Works with pandas and numpy

Installation

Installation process is simple, just:

$ pip install mldissect

Basic Usage

# lets train a model
boston = load_boston()
columns = list(boston.feature_names)
X, y = boston['data'], boston['target']
X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=.2, random_state=seed
)

clf = LassoCV()
clf.fit(X_train, y_train)

# select first observation in test split
observation = X_test[0]
# RegressionExplainer uses training data or sample of training data
# for large dataset to figure out contributions of each feature
explainer = RegressionExplainer(clf, X_train, columns)
result = explainer.explain(observation)
# print/visualize explanation
explanation = Explanation(result)
explanation.print()

result:

+----------+---------+--------------------+
| Feature  | Value   | Contribution       |
+----------+---------+--------------------+
| baseline | -       | 22.611881188118804 |
| LSTAT    | 7.34    | 3.6872             |
| PTRATIO  | 16.9    | 1.3652             |
| CRIM     | 0.06724 | 0.2323             |
| B        | 375.21  | 0.1195             |
| RM       | 6.333   | 0.0411             |
| INDUS    | 3.24    | 0.0312             |
| CHAS     | 0.0     | 0.0                |
| NOX      | 0.46    | 0.0                |
| TAX      | 430.0   | -0.3794            |
| AGE      | 17.2    | -0.5127            |
| ZN       | 0.0     | -0.6143            |
| DIS      | 5.2146  | -1.0792            |
| RAD      | 4.0     | -1.0993            |
+----------+---------+--------------------+

Algorithm

Algorithm is based on ideas describe in paper “Explanations of model predictions with live and breakDown packages” https://arxiv.org/abs/1804.01955

Difference with pyBreakDown

pyBreakDown is similar project, but there is key differences:

  • mldissect is maintained

  • Has tests and good code coverage.

  • Classification is working properly.

  • Multi class support.

  • Top down approach is not implemented.

  • Friendly license.

Requirements

CHANGES

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

mldissect-0.0.1a2.tar.gz (8.7 kB view details)

Uploaded Source

File details

Details for the file mldissect-0.0.1a2.tar.gz.

File metadata

  • Download URL: mldissect-0.0.1a2.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.7

File hashes

Hashes for mldissect-0.0.1a2.tar.gz
Algorithm Hash digest
SHA256 76076b4cbe86a09c9e038785b62ec6ca18682fee9f2fccbc39711a09a1da7d86
MD5 78192f0f66780678a99303b1de86a435
BLAKE2b-256 f0170a2c31d9a6d70c6347c3f254fa757fe5b60944dc19bb9af82b18d033ffd0

See more details on using hashes here.

Provenance

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