Skip to content

Commit

Permalink
import shap in try except block
Browse files Browse the repository at this point in the history
  • Loading branch information
pplonski committed Nov 8, 2024
1 parent 9addf1c commit 5dad220
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion supervised/utils/shap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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"]:
Expand Down

0 comments on commit 5dad220

Please sign in to comment.