Skip to content

Commit

Permalink
Merge 3d645e9 into 72cea54
Browse files Browse the repository at this point in the history
  • Loading branch information
mwmclean committed Jun 19, 2019
2 parents 72cea54 + 3d645e9 commit 5f48d30
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: flipTrees
Type: Package
Title: Tools for classification and regression trees
Version: 1.0.0
Version: 1.0.1
Author: Displayr <opensource@displayr.com>
Maintainer: Displayr <opensource@displayr.com>
Description: Wrappers for classification and regression trees using the flip
Expand Down
8 changes: 8 additions & 0 deletions R/cart.R
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,11 @@ predict.CART <- function(object, newdata = NULL, seed = 1232, ...)
CheckPredictionVariables(object, newdata)

class(object) <- "rpart"

## old CART outputs used outcome.numeric instead of numeric.outcome; DS-2488
if (is.null(object$numeric.outcome))
object$numeric.outcome <- object$outcome.numeric

type <- ifelse(object$numeric.outcome, "vector", "class")

# If error or exclude missing data, then predict NA for cases with any missing data.
Expand All @@ -356,6 +361,9 @@ flipData::Probabilities
#' @export
Probabilities.CART <- function(object, ...)
{
## old CART outputs used outcome.numeric instead of numeric.outcome; DS-2488
if (is.null(object$numeric.outcome))
object$numeric.outcome <- object$outcome.numeric
if(object$numeric.outcome)
stop("Probabilities not available for numeric dependent variables.")

Expand Down
Binary file added tests/testthat/oldCART.rda
Binary file not shown.
5 changes: 5 additions & 0 deletions tests/testthat/test-CART.R
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,8 @@ test_that("Many factor levels", {
fixed = TRUE)
})

test_that("predict method works with old outputs; DS-2488",
{
load("oldCART.rda")
expect_error(predict(cart), NA)
})

0 comments on commit 5f48d30

Please sign in to comment.