diff feature_importance.py @ 7:0afd970bd8ae draft default tip

planemo upload for repository https://github.com/goeckslab/gleam commit 55deacbbc78a00f27d789e11d563ba49dfb9cf9e
author goeckslab
date Fri, 22 Aug 2025 21:13:44 +0000
parents 11fdac5affb3
children
line wrap: on
line diff
--- a/feature_importance.py	Fri Aug 01 14:02:13 2025 +0000
+++ b/feature_importance.py	Fri Aug 22 21:13:44 2025 +0000
@@ -136,10 +136,15 @@
 
         predict_fn = model.predict_proba if hasattr(model, "predict_proba") else model.predict
 
-        explainer = shap.Explainer(predict_fn, bg)
-        self.shap_model_name = explainer.__class__.__name__
+        try:
+            explainer = shap.Explainer(predict_fn, bg)
+            self.shap_model_name = explainer.__class__.__name__
 
-        shap_values = explainer(X_data)
+            shap_values = explainer(X_data)
+        except Exception as e:
+            LOG.error(f"SHAP computation failed: {e}")
+            self.shap_model_name = None
+            return
 
         output_names = getattr(shap_values, "output_names", None)
         if output_names is None and hasattr(model, "classes_"):