giuseppec / giuseppec/iml

Error message from TreeSurrogate$new

Open
#143 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
R
Stars
503
Forks
87
PR merge metrics
No merged PRs in 30d

Description

First, I used my own data set and I got "Error in model.frame.default(terms(formula, lhs = lhs, rhs = rhs, data = data, :
variable lengths differ (found for '0')" after using the TreeSurrogate function...

So I tested it again using a simple simulated data:

x1 <- rnorm(100,0,1)
x2 <- rnorm(100,0,1)
x3 <- rnorm(100,0,1)
xb <- -1 + 2*x1 + 1*x2 - 3*x3
p <- 1/(1 + exp(-xb))
y <- rbinom(n = 100, size = 1, prob = p)
y <- as.factor(y)
dt <- data.frame(x1,x2,x3,y)

rf <- randomForest(y ~ ., data = dt, ntree = 50)
dt2 <- dt[-which(names(dt) == "y")]
predictor <- Predictor$new(rf, data = dt2)
res <- TreeSurrogate$new(predictor, maxdepth = 2)

And I still got the same error message "Error in model.frame.default(terms(formula, lhs = lhs, rhs = rhs, data = data, :
variable lengths differ (found for '0')"...

No sure what I did wrong. BTW, there is no error message using the IRIS data...

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.