Fix bug where predicting on regression forest with no newData caused
crash.
This commit is contained in:
parent
3f0f6c0878
commit
3fa2fef82a
2 changed files with 2 additions and 1 deletions
|
@ -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)
|
predictionsJava <- .jcall(forestObject, makeResponse(.class_List), function.to.use, predictionDataList)
|
||||||
|
|
||||||
if(predictionClass == "numeric"){
|
if(predictionClass == "numeric"){
|
||||||
predictions <- vector(length=nrow(newData), mode="numeric")
|
predictions <- vector(length=numRows, mode="numeric")
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
predictions <- list()
|
predictions <- list()
|
||||||
|
|
|
@ -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)
|
forest <- train(y ~ x, trainingData, ntree=50, numberOfSplits=0, mtry=1, nodeSize=5, cores=2, displayProgress=FALSE)
|
||||||
|
|
||||||
predictions <- predict(forest, testData)
|
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
|
expect_true(T) # show Ok if we got this far
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue