法士泰的塑形包装纸
fastshapv1的Python项目详细描述
快速成形(V1) >;此项目将SHAP库的一部分引入fastai(V1),并使其兼容。感谢Nestor Demeure对项目的帮助!在
##安装
pip安装fastshap
如何使用
首先,我们将快速训练成人的表格模型
` 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') `
Classification model detected, displaying score for the class <50k. (use class_id to specify another class)
啊![png](docs/images/output_13_2.png)
有关更多示例,请参见[01_Interpret](https://muellerzr.github.io/fastshap//interpret)
有关更多非官方的fastai扩展,请参阅[fastai扩展库](https://github.com/nestordemeure/fastai-extensions-repository).
- 项目
标签: