mldissect - 模型无关解释
项目描述
mldissect
mldissect是一个模型无关的预测解释器,该库可以显示预测值中每个特征的贡献。
特性
支持分类和回归的预测解释
易于使用的API。
与pandas和numpy兼容
安装
安装过程简单,只需
$ 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的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 76076b4cbe86a09c9e038785b62ec6ca18682fee9f2fccbc39711a09a1da7d86 |
|
MD5 | 78192f0f66780678a99303b1de86a435 |
|
BLAKE2b-256 | f0170a2c31d9a6d70c6347c3f254fa757fe5b60944dc19bb9af82b18d033ffd0 |