Error when using predict on bartmachine object

119 Views Asked by At

I am writing the following script:

#options(java.parameters = "-Xmx50000m")
library(bartMachine)
library(tidyverse)

data <- data.frame(x=rnorm(100, 5, 2), 
                   z=rnorm(100, 1, 0.5), 
                   y=as.factor(rep(c("a", "b"), 100)))

model <-  bartMachine(X= data[,c("x", "z")],
                           y= data$y, seed = 999,
                           serialize = T)

test <- data.frame(x=rnorm(1000, 5, 2.5), 
                   z=rnorm(1000, 1, 0.7))

pred <- predict(model, test)

On my real world example, I get the following message when calling predict:

Error in validObject(.Object) : invalid class “jobjRef” object: invalid object for slot "jobj" in class "jobjRef": got class "NULL", should be or extend class "externalptr"

Has anyone seen this error before? I haven't been able to find much online. Apologies for not being able to replicate the issue.

@Sean posted about a similar error message.

1

There are 1 best solutions below

0
On

Increasing memory allocation resolved the issue:

options(java.parameters = "-Xmx500000m")