Skip to content

Commit

Permalink
Update prescriptive warning message (grf-labs#1040)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikcs authored Aug 25, 2021
1 parent 6684b14 commit b2d4575
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions r-package/grf/R/multi_arm_causal_forest.R
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ multi_arm_causal_forest <- function(X, Y, W,
if (nlevels(W) == 1) {
stop("Can not compute contrasts from a single treatment.")
}
if (!identical(levels(W), levels(droplevels(W)))) {
warning("The treatment vector W contains unused levels.")
if (nlevels(W) != nlevels(droplevels(W))) {
warning("The treatment vector W contains unused levels (see `droplevels()` to drop unused levels).")
}

args.orthog <- list(X = X,
Expand Down
4 changes: 2 additions & 2 deletions r-package/grf/R/probability_forest.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ probability_forest <- function(X, Y,
if (!is.factor(Y)) {
stop("The class labels must be a factor vector.")
}
if (!identical(levels(Y), levels(droplevels(Y)))) {
warning("The class label vector Y contains unused levels.")
if (nlevels(Y) != nlevels(droplevels(Y))) {
warning("The class label vector Y contains unused levels (see `droplevels()` to drop unused levels).")
}
Y.relabeled <- as.numeric(Y) - 1 # convert to integers between 0 and num_classes
class.names <- levels(Y)
Expand Down

0 comments on commit b2d4575

Please sign in to comment.