From 5dad220e88fae1ddd7cea5b538e0f1ca55f16c3b Mon Sep 17 00:00:00 2001 From: Piotr Date: Fri, 8 Nov 2024 15:49:41 +0100 Subject: [PATCH] import shap in try except block --- supervised/utils/shap.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/supervised/utils/shap.py b/supervised/utils/shap.py index cbd2abc1..f5c174b5 100644 --- a/supervised/utils/shap.py +++ b/supervised/utils/shap.py @@ -4,7 +4,15 @@ import matplotlib.pyplot as plt import numpy as np import pandas as pd -import shap +shap_pacakge_available = False +try: + # I'm tired of all shap dependency hell + # ugh + import shap + shap_pacakge_available = True +except Exception: + pass + from sklearn.preprocessing import OneHotEncoder from supervised.algorithms.registry import ( @@ -23,6 +31,8 @@ class PlotSHAP: @staticmethod def is_available(algorithm, X_train, y_train, ml_task): + if not shap_pacakge_available: + return False # https://github.com/mljar/mljar-supervised/issues/112 disable for NN # https://github.com/mljar/mljar-supervised/issues/114 disable for CatBoost if algorithm.algorithm_short_name in ["Baseline", "Neural Network", "CatBoost"]: