跳转到主要内容

fastai的shap包装器

项目描述

# FastSHAP (V1) > 此项目将部分SHAP库引入fastai (V1)并使其兼容。感谢Nestor Demeure在此项目中提供的帮助!

## 安装

pip install fastshap

## 使用方法

首先,我们将快速训练一个ADULTS表格模型

` from fastai2.tabular.all import * `

` path = untar_data(URLs.ADULT_SAMPLE) df = pd.read_csv(path/'adult.csv') `

` dep_var = 'salary' cat_names = ['workclass', 'education', 'marital-status', 'occupation', 'relationship', 'race'] cont_names = ['age', 'fnlwgt', 'education-num'] procs = [Categorify, FillMissing, Normalize] `

` splits = IndexSplitter(list(range(800,1000)))(range_of(df)) to = TabularPandas(df, procs, cat_names, cont_names, y_names="salary", splits=splits) dls = to.dataloaders() `

` learn = tabular_learner(dls, layers=[200,100], metrics=accuracy) learn.fit(1, 1e-2) `

现在,让我们看看一些示例用法!

` from fastshap.interp import * `

` exp = ShapInterpretation(learn, df.iloc[:100]) `

` exp.dependence_plot('age') `

分类模型检测到,显示 <50k 类的分数。(使用 class_id 指定其他类别)

![png](docs/images/output_13_2.png)

更多示例请参阅 [01_Interpret](https://muellerzr.github.io/fastshap//interpret

更多非官方 fastai 扩展,请参阅 [Fastai 扩展存储库](https://github.com/nestordemeure/fastai-extensions-repository)。

项目详情


下载文件

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

源分布

fastshapv1-0.0.10.tar.gz (10.9 kB 查看哈希值)

上传时间

构建分布

fastshapv1-0.0.10-py2-none-any.whl (7.4 kB 查看哈希值)

上传时间 Python 2

支持