简体   繁体   English

逻辑回归的沙普利?

[英]Shapley for Logistic regression?

Does shapley support logistic regression models? shapley 是否支持逻辑回归模型?

Running the following code i get:运行以下代码我得到:

logmodel = LogisticRegression()
logmodel.fit(X_train,y_train)
predictions = logmodel.predict(X_test)
explainer = shap.TreeExplainer(logmodel )

Exception: Model type not yet supported by TreeExplainer: <class 'sklearn.linear_model.logistic.LogisticRegression'>

PS You are supposed to use a different explainder for different models PS您应该为不同的模型使用不同的解释器

Shap is model agnostic by definition.根据定义,Shap 与模型无关。 It looks like you have just chosen an explainer that doesn't suit your model type.看起来您刚刚选择了一个不适合您的模型类型的解释器。 I suggest looking at KernelExplainer which as described by the creators here is我建议查看KernelExplainer ,正如这里的创建者所描述的那样

An implementation of Kernel SHAP, a model agnostic method to estimate SHAP values for any model.内核 SHAP 的实现,这是一种模型不可知的方法,用于估计任何模型的 SHAP 值。 Because it makes not assumptions about the model type, KernelExplainer is slower than the other model type specific algorithms.因为它不对模型类型做出假设,所以 KernelExplainer 比其他模型类型特定算法慢。

The documentation for Shap is mostly solid and has some decent examples. Shap 的文档大多是可靠的,并且有一些不错的例子。

explainer = shap.LinearExplainer(logmodel)应该工作,因为逻辑回归是一个线性模型。

Logistic 回归是一个线性模型,因此您应该使用线性解释器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM