I am training my SVC model and I am getting this error with the Shap Library. Have tried some methods including shap.maskers.Independent but the same error keeps appearing. Am I missing out something?
Codes
model = SVC (C = 10.0, gamma = 0.01, kernel = 'rbf', probability=True)
model.fit(X_resampled,y_resampled)
y_predict= model.predict_proba(X_resampled_test)[:,1] # for AUC calculation, ploting ROC-AUC and Precision_
from sklearn.metrics import log_loss
print("Log-loss on logit: {:6.4f}".format(log_loss(y_resampled_test, y_predict)))
plt.figure()
# # #Get shap values
# feature_names = X_train.columns
explainer = shap.KernelExplainer(model.predict_proba, X_resampled, link="logit")
shap_values = explainer(X_resampled, X_resampled_test)
Error
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_22576/2256358008.py in <module>
4 # feature_names = X_train.columns
5 explainer = shap.KernelExplainer(model.predict_proba, X_resampled, link="logit")
----> 6 shap_values = explainer(X_resampled, X_resampled_test)
c:\Users\danie\anaconda3\lib\site-packages\shap\explainers\_explainer.py in __call__(self, max_evals, main_effects, error_bounds, batch_size, outputs, silent, *args, **kwargs)
205 start_time = time.time()
206
--> 207 if issubclass(type(self.masker), maskers.OutputComposite) and len(args)==2:
208 self.masker.model = models.TextGeneration(target_sentences=args[1])
209 args = args[:1]
AttributeError: 'Kernel' object has no attribute 'masker
You may wish to try the following: