Fix bug where predicting on regression forest with no newData caused

crash.
This commit is contained in:
Joel Therrien 2019-09-08 17:03:41 -07:00
parent 3f0f6c0878
commit 3fa2fef82a
2 changed files with 2 additions and 1 deletions

View file

@ -99,7 +99,7 @@ predict.JRandomForest <- function(object, newData=NULL, parallel=TRUE, out.of.ba
predictionsJava <- .jcall(forestObject, makeResponse(.class_List), function.to.use, predictionDataList)
if(predictionClass == "numeric"){
predictions <- vector(length=nrow(newData), mode="numeric")
predictions <- vector(length=numRows, mode="numeric")
}
else{
predictions <- list()

View file

@ -28,6 +28,7 @@ test_that("Regresssion doesn't crash", {
forest <- train(y ~ x, trainingData, ntree=50, numberOfSplits=0, mtry=1, nodeSize=5, cores=2, displayProgress=FALSE)
predictions <- predict(forest, testData)
other_predictions <- predict(forest) # there was a bug if newData wasn't provided.
expect_true(T) # show Ok if we got this far