pbiecek / breakDown

Model Agnostics breakDown plots
https://pbiecek.github.io/breakDown/
103 stars 16 forks source link

Help: Error in yhats[[which.min(yhats_diff)]] #29

Open Margarida-F opened 4 years ago

Margarida-F commented 4 years ago

Hi !

Can I have help to fix the error below?

Error in yhats[[which.min(yhats_diff)]] : attempt to select less than one element in get1index

I only code this:

contribution <- broken(model = model, new_observation = df[1,features], data = train[,features])

and my model is a randomForest.

It seems that is trying to access to the zero position, and it doesn't exist.

Thanks, Margarida

pbiecek commented 4 years ago

Do you have a reproducible example that produces this error? And please try the iBreakDown package (https://github.com/ModelOriented/iBreakDown) with break_down) function, it's a newer version so maybe this problem is already solved there

Margarida-F commented 4 years ago

First of all, thanks for you answer.

I suppose I can't show the data but I guarantee the variables are all right. However, maybe the problem is the model...

I try this:

contribution <- break_down(model, new_observation = df[1,features], data = train[,features]) Error in colMeans(yhatpred) : 'x' must be numeric

And then, tried construct explainer first:

explainer <- explain(model,data=train[,features],y=train$Y) Error in UseMethod("explain") : no applicable method for 'explain' applied to an object of class "c('randomForest.formula', 'randomForest')"

My model is like: model

Can you help me, please?

Thank you, very much , Margarida

pbiecek commented 4 years ago

Can you share devtools::session_info()? It is hard to suggest anything without knowing on which versions of DALEX/breakDown you are working. Try latest versions DALEX & iBreakDown from CRAN.

If this is not enough then try to change thy y variable from factor to numeric (as Y == "1")

Margarida-F commented 4 years ago

Hi, again. Thank you very much you're trying to help me.

My Session Information is:

[1] C:/Users/Margarida Ferreira/Documents/R/win-library/3.5 [2] C:/Program Files/R/R-3.5.2/library

Change Y to numeric doesn't works because Y isn't an argument of break_down().

Should I download the code and run each code block to debug?

Thanks for everything, Margarida

Margarida-F commented 4 years ago

Hi, again.

Just to close this issue:

I'm now using some code of iBreakDown. It's normal that it take too long (around 8 minutes) to calculate contributions of 13 variables and 1 row?

Thanks very much. I promise I close this issue before your answer.

Margarida

pbiecek commented 4 years ago

Hi, busy time ar university, sorry for late response.

iBreakDown is much faster than breakDown. For FIFA data (200k cases, ~100 variables) calculation of break down is below a minute, do for 13 variables it shall be seconds at most.

Here you will find how to use the most recent version of iBreakDown https://pbiecek.github.io/PM_VEE/breakDown.html#BDR