NorskRegnesentral/shapr

model error

Shamimashrafiyan91 opened this issue · 1 comments

Hi!
I have a model which I got it from an MLP, actually, I defined a search grid and find the best model, and saved it. I used "keras_model_sequentia" in R for training(I wrote my code completely in R). So I have an hdf5 file as my model. I loaded it somehow. I wanted to find the shape values (important features). So I used your package, with my dataset and also built-in datasets but it showed me this error:
Error in get_model_specs(model) :
You passed a model to shapr which is not natively supported See ?shapr::shapr or the vignette
for more information on how to run shapr with custom models.

I also checked the table and MLP wasn't there! are you planning to consider this type of model or do you have any ideas to find the shape for these models? I have 50000 of this model!

BTW, when I wanted to load my model I got some errors so I had to use Python in R and load it. the output of class(model) is:
[1] "keras.engine.sequential.Sequential"
[2] "keras.engine.functional.Functional"
[3] "keras.engine.training.Model"
[4] "keras.engine.base_layer.Layer"
[5] "tensorflow.python.module.module.Module"
[6] "tensorflow.python.trackable.autotrackable.AutoTrackable"
[7] "tensorflow.python.trackable.base.Trackable"
[8] "keras.utils.version_utils.LayerVersionSelector"
[9] "keras.utils.version_utils.ModelVersionSelector"
[10] "python.builtin.object"

Thanks in advance.

Hi, and sorry for the late reply

As long as your model can perform prediction on data in R, you can use shapr to explain your predictions.
For custom models like your keras model, you need to write the prediction function yourself (typically very easy), see

https://norskregnesentral.github.io/shapr/articles/understanding_shapr.html#explain-custom-models

Hope this helps.