待苇成则荻成 2023-11-04 21:15 采纳率: 33.3%
浏览 298

SHAP模型实现LSTM模型可解释性

各位,我想请教一下。我搜到的都是使用SHAP模型解释随机森林,xgboost等,而几乎没有解释LSTM模型的。从理论上来说SHAP模型能够解释几乎一切模型,那应该不需要使用额外的模型和它结合。但是实在是不知道应该怎么修改

```python
import xgboost
import shap
import pandas
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib import rcParams
rcParams.update(config)

train an XGBoost model

shap.initjs()
X = pandas.read_excel("LSTM2.xlsx")
y = np.loadtxt("y2.txt")
model = xgboost.XGBRegressor().fit(X, y)

explain the model's predictions using SHAP

explainer = deepExplainer(model, X)
shap_values = explainer(X)
shap.summary_plot(shap_values, X, plot_type="bar")
plt.show()
``` ,求指教!!!

  • 写回答

3条回答 默认 最新

  • 好好学仿真 2025-12-11 16:39
    关注

    shap库合金力学性能预测模型分析,机器学习数据驱动加速金属材料设计相关前沿可查看:某公某号:研而有信er,详查:

    评论

报告相同问题?

问题事件

  • 修改了问题 11月4日
  • 创建了问题 11月4日