Python 逻辑回归的Shapley?

Python 逻辑回归的Shapley?,python,machine-learning,data-science,logistic-regression,shap,Python,Machine Learning,Data Science,Logistic Regression,Shap,shapley支持逻辑回归模型吗 运行我得到的以下代码: 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.

shapley支持逻辑回归模型吗

运行我得到的以下代码:

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'>
logmodel=logistic回归()
logmodel.fit(X_系列、y_系列)
预测=对数模型预测(X_检验)
explainer=shap.treeeexplainer(logmodel)
例外:TreeExplainer尚不支持模型类型:

另外,对于不同的模型,你应该使用不同的解释者。

根据定义,形状是模型不可知的。看起来您刚刚选择了一个不适合您的模型类型的解释者。我建议查看内核解释程序,正如创建者所描述的那样

内核SHAP的一种实现,一种模型不可知的方法,用于估计任何模型的SHAP值。由于KernelExplainer没有对模型类型进行假设,因此它比其他特定于模型类型的算法要慢


Shap的文档大部分是可靠的,并且有一些不错的例子

逻辑回归是一个线性模型,所以你应该使用线性解释者。

逻辑回归是一个线性模型。

我明白了。谢谢,这比我想象的要简单,我很感激,没问题。很高兴这有帮助。