Closed edvardoss closed 5 years ago
Thanks for reporting, I did not think to test with an all factor dataset. Will fix this as soon as possible
get_data_space now work, thank you! But next step - not.
library(ranger)
m <- ranger(formula = Survived~.,data = d,mtry = 6,min.node.size = 5, num.trees = 600,
importance = "permutation")
library(easyalluvial)
imp <- importance(m) %>% as.data.frame %>% tidy_imp(imp = .,df=d)
dspace <- get_data_space(df = d,imp,degree = 4) # Work!
pred = predict(m, data = dspace)
p = alluvial_model_response(pred, dspace, imp, degree = 4) # Error in alluvial_model_response: "pred" needs to be a numeric or a factor vector
fixing some issues that arise when having character and factors in the training data eb74c372c7218ea393288cfe42e454bf91220fe4
Hi sorry Ia am not as frequently checking back on this as I would like to. So The problem is with predict
in the ranger
package it does not return pure predictions but returns some kind of list that needs to be indexed to get to the predictions.
try:
p = alluvial_model_response(pred = pred$predictions, dspace = gds, imp = imp, degree = 4)
this works for me. Could you install the most recent development version? And tell me if it works for you now? Including the caret
bit?.
Thanks for reporting this, it uncovered a few issues when using factors that I should have anticipated. I have added your example as a new test case. It will go to CRAN in the next two weeks hopefully.
Hi! Yes, i'm install latest dev.version. Sorry for ranger::predict - i am not properly checked this object type, thank you for your answer, its work well! But caret still generate error for me:
# ok, don`t give up and try caret
devtools::install_local(path = "C:\\Users\\AnanevHA\\Downloads\\easyalluvial-master",force = TRUE)
library(caret)
trc <- trainControl(method = "none")
m <- train(Survived~.,data = d,method="rf",trControl=trc,importance=T)
library(easyalluvial)
alluvial_model_response_caret(train = m,degree = 4,bins=5,stratum_label_size = 2.8) # Error in tidy_imp(imp, df) : not all listed important variables found in input data
Could you make sure that you have the latest dev version installed
devtools::install_github('https://github.com/erblast/easyalluvial.git')
When you execute easyalluvial::tidy_imp
you see the function source code. You should find the following lines.
# correct dummyvariable names back to original name
df_ori_var = tibble( ori_var = names( select_if(df, ~ is.factor(.) | is.character(.) ) ) ) %>%
not the | is.character(.)
was added. This should resolve the error you were getting.
Let me know how it goes.
Hi! Everything is working, thank you!
I’m impressed while reading your blog about model interpretation and try to test this package on popular dataset “titanic” but all my attemtions is failed.