mirror of
https://github.com/msitarzewski/agency-agents.git
synced 2026-10-20 10:19:59 +00:00
fix(model-qa): explain regressors through the prediction fallback
Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>
This commit is contained in:
@@ -239,9 +239,8 @@ def shap_global_analysis(model, X: pd.DataFrame, output_dir: str = ".",
|
||||
try:
|
||||
explainer = shap.TreeExplainer(model)
|
||||
except Exception:
|
||||
explainer = shap.KernelExplainer(
|
||||
model.predict_proba, shap.sample(X, 100)
|
||||
)
|
||||
predict = model.predict_proba if hasattr(model, "predict_proba") else model.predict
|
||||
explainer = shap.KernelExplainer(predict, shap.sample(X, 100))
|
||||
|
||||
shap_values = explainer.shap_values(X)
|
||||
|
||||
@@ -284,9 +283,8 @@ def shap_local_explanation(model, X: pd.DataFrame, idx: int,
|
||||
try:
|
||||
explainer = shap.TreeExplainer(model)
|
||||
except Exception:
|
||||
explainer = shap.KernelExplainer(
|
||||
model.predict_proba, shap.sample(X, 100)
|
||||
)
|
||||
predict = model.predict_proba if hasattr(model, "predict_proba") else model.predict
|
||||
explainer = shap.KernelExplainer(predict, shap.sample(X, 100))
|
||||
|
||||
explanation = explainer(X.iloc[[idx]])
|
||||
if explanation.values.ndim == 3:
|
||||
|
||||
Reference in New Issue
Block a user