bgreenwell/pdp

Is it possible to feed 3D arrays that

koheihasegawamd opened this issue · 3 comments

Hi,
Thank you so much for providing the wonderful package! I am wondering if it is possible to draw ICE curves and obtain a PDP using the output from a KERAS LSTM/RNN (e.g., 3-to-3 regression RNN).

Let X_array be the predictors (2 samples * 3 time steps * 4 features) and Y_array be the outcome (2 samples * 3 time steps * 1 numeric outcome):
X_array <- array(seq(1,24), dim=c(2,3,4))
Y_array <- array(rnorm(6, 0, 1), dim=c(2,3,1))
Let keras_model be the LSTM (3-to-3 RNN) model that is constructed/fitted.

Would it be possible to feed these into the PDP partial function (and vip)? If yes, how so?

Thank you very much!

Hi @koheihasegawamd, thank you for the kind words! Essentially, as long as you can provide a wrapper to obtain predictions on new data, pdp and vip can accommodate. Unfortunately, I know very little about Keras. Do you have a reproducible example/model I can use on my end? FYI, I do have a TensorFlow/Keras regression example with pdp and vip here: https://koalaverse.github.io/vip/articles/vip-tensorflow.html.

Thanks so much for the response.

In Python, I was able to feed 3d tensors (Keras input and output) into a SHAP function. I will try to make a wrapper to feed it within your package.

Sounds good @koheihasegawamd! Also, theoretically, you can still use pdp with your Python model! Here's a simple example: https://bgreenwell.github.io/pdp/articles/pdp-reticulate.html