ModelOriented / DALEXtra

Extensions for the DALEX package
https://ModelOriented.github.io/DALEXtra/
65 stars 10 forks source link

Creating the explainer: predict_function returns an error when executed #61

Closed Sunwitch91 closed 3 years ago

Sunwitch91 commented 3 years ago

Hello!

This is my first time using Dalextra and I am struggling creating an explainer. I have a tensorflow/keras regression model created in python that I load into R. I create the explainer like this: explmod = explain_keras('model2.p', yml = "/home/user/environment.yml", predict_function = yhat, type = 'regression', condaenv = '/home/user/anaconda3/', data = train_x,y = train_y)

I have tried predict_function = predict' andyhat` and also leaving it empty. In any case, my output is like this:

`Preparation of a new explainer is initiated

-> model label : keras ( default )

-> data : 175200 rows 96 cols

-> target variable : 175200 values

-> predict function : predict_function

-> predicted values : the predict_function returns an error when executed ( WARNING )

-> model_info : package reticulate , ver. 1.18 , task classification ( default )

-> model_info : type set to regression

-> residual function : difference between y and yhat ( default )

-> residuals : the residual_function returns an error when executed ( WARNING )

A new explainer has been created!`

If I call predict() or yhat() separately, they work and can predict, though. Can anyone tell me what I'm doing wrong? Thanks in advance!

Edit: So by now I have found out that the pickle function I used was suboptimal, I also noticed that the explainer recognized a classification task instead of a regression. After using a different pickle funcion, the explainer correctly idenifies regression, but the prediction function still throws an error. Is it possible that the dimensions of the x and y variables matter? Normally,the x-variable is 3d and the y-variable is 2d. I also tried a 3d and a 1d y-variable, but neither works.

Can DALEXtra even handle lstms?

maksymiuks commented 3 years ago

Hi!

could you provide me with a .pkl file, data, and .yml via email? They can be anonymized. DALEXtra should handle it but I find it really hard to help without the code. Also keras changes recently so perhaps DALEXtra code needs some changes. My email is sz.maksymiuk@gmail.com

answering your question from the edit dimension indeed matters. R (on the reticulate side) has to be able to transform them into object understandable for keras model.

Sunwitch91 commented 3 years ago

Hello!

That is very nice of you, thank you! I just send you an email with everything. If you need anything else, I'll be glad to provide =)