跳转到主要内容

mldissect - 模型无关解释

项目描述

mldissect

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

mldissect是一个模型无关的预测解释器,该库可以显示预测值中每个特征的贡献。

特性

  • 支持分类和回归的预测解释

  • 易于使用的API。

  • pandasnumpy兼容

安装

安装过程简单,只需

$ pip install mldissect

基本用法

# 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()

结果

+----------+---------+--------------------+
| 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            |
+----------+---------+--------------------+

算法

算法基于论文《使用live和breakDown包解释模型预测》中的思想 “Explanations of model predictions with live and breakDown packages” https://arxiv.org/abs/1804.01955

与pyBreakDown的区别

pyBreakDown是一个类似的项目,但存在一些关键区别

  • mldissect得到维护

  • 有测试和良好的代码覆盖率。

  • 分类工作正常。

  • 支持多分类。

  • 没有实现自顶向下的方法。

  • 友好的许可证。

要求

更改

项目详情


下载文件

下载您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分发

mldissect-0.0.1a2.tar.gz (8.7 kB 查看哈希值)

上传时间 源代码

支持者