Skip to content

Conversation

fleur101
Copy link

Extend init_explainer to work with different models
Use TreeExplainer for tree-based models, DeepExpainer for deep elarning models, and KernelExplainer for the rest

prefix_int = int(prefix_target.strip('/').split('_')[1])-1

explainer = _init_explainer(model)
explainer = _init_explainer(model, training_df)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The explanation object contains a reference to the predictive_model, please pass to the function you customised the 'prediction_method' string contained in the PredictiveModel, otherwise your code will never be executed.

if model_type in [ClassificationMethods.PERCEPTRON.value,
ClassificationMethods.NN.value]:
return shap.DeepExplainer(model, df)
return shap.KernelExplainer(model)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure the shap.KernelExplainer function takes only 'model' as parameter?

Initialises the explainer according to the model type
:param model: model to explain
:param df: model training data
:param model_type: model type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rewrite in:
:param model_type: one of ClassificationMethods enumerator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants