Skip to content

Commit

Permalink
Bugfix edge case where party returns a constparty object (#423)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinju authored Nov 25, 2024
1 parent 2a3d088 commit 5a52e6a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion R/approach_ctree.R
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,23 @@ sample_ctree <- function(tree,
colnames(xp) <- paste0("V", given_ind) # this is important for where() below

if (using_partykit) {
# xp here needs to contain the response variables as well, for some reason
x_explain_dependent <- x_explain[,
dependent_ind,
drop = FALSE,
with = FALSE
]

colnames(x_explain_dependent) <- paste0("Y", seq_along(dependent_ind))
xp2 <- cbind(xp, x_explain_dependent)

fit.nodes <- predict(
object = datact,
type = "node"
)
# newdata must be data.frame + have the same colnames as x
pred.nodes <- predict(
object = datact, newdata = xp,
object = datact, newdata = xp2,
type = "node"
)
} else {
Expand Down

0 comments on commit 5a52e6a

Please sign in to comment.