ModelOriented / modelStudio

📍 Interactive Studio for Explanatory Model Analysis
https://doi.org/10.1007/s10618-023-00924-w
GNU General Public License v3.0
326 stars 32 forks source link

Parsing error for only one variable model #99

Closed JohnsonHsieh closed 3 years ago

JohnsonHsieh commented 3 years ago

Dear Maintainer

I found that modelStudio would not allow a model_explainer object when model has only one variable. There is the following example:

titanic_imputed_sub <- subset(titanic_imputed, select = c("survived", "class"))
model_titanic <- glm(survived ~ class, data = titanic_imputed_sub, family = "binomial")

# create an explainer for the model
explainer_titanic <- explain(model_titanic,
                             data = titanic_imputed_sub,
                             y = titanic_imputed$survived,
                             label = "Titanic GLM")

# pick observations
new_observations <- titanic_imputed[1:2,]
rownames(new_observations) <- c("Lucas","James")

# make a studio for the model
modelStudio(explainer_titanic,
            new_observations, eda=FALSE,
            N = 200,  B = 5)
  Calculating ... 
  Calculating ingredients::feature_importance 
    Elapsed time: 00:00:00 ETA: 0s Error in `[.default`(data, , , drop = FALSE) : 維度數目不正確
此外: Warning message:
In value[[3L]](cond) : 
Error occurred in ingredients::feature_importance function: 長度為 0 的引數
Called from: NextMethod("[")
hbaniecki commented 3 years ago

Thanks! This will be fixed with the next versions of the corresponding packages.