kapelner/bartMachine

v1.2.5.1 cannot read v1.2.5.0 object

Closed this issue · 3 comments

I use bartMachine together with caret. As recommended, I always turn the option serialize to TRUE in train. However, I noticed that bartMachine v1.2.5.1 is not able to use model created by bartMachine v1.2.5.0. I receive the following error message:

Error in check_serialization(object) :
This bartMachine object was loaded from an R image but was not serialized.
Please build bartMachine using the option "serialize = TRUE" next time.

Edit
This is reproducible with the example from ?bartMachine

library(bartMachine)  ### Here version 1.2.5.0 is mandatory

## Generate Friedman data
set.seed(11)
n  = 200 
p = 5
X = data.frame(matrix(runif(n * p), ncol = p))
y = 10 * sin(pi* X[ ,1] * X[,2]) +20 * (X[,3] -.5)^2 + 10 * X[ ,4] + 5 * X[,5] + rnorm(n)

## Build BART regression model
bart_machine = bartMachine(X, y, serialize = TRUE)
summary(bart_machine)

bartMachine v1.2.3 for regression

training data n = 200 and p = 5 
built in 0.8 secs on 1 core, 50 trees, 250 burn-in and 1000 post. samples

sigsq est for y beforehand: 7.281 
avg sigsq estimate after burn-in: 0.76294 

in-sample statistics:
 L1 = 104.28 
 L2 = 92.58 
 rmse = 0.68 
 Pseudo-Rsq = 0.9801
p-val for shapiro-wilk test of normality of residuals: 0.0258 
p-val for zero-mean noise: 0.41082 


## Save the bartMachine object
saveRDS(bart_machine, "~/bartMachine_version1.2.5.0.rda")

Now we upgrade bartMachine to version 1.2.5.1

bart_machine <- readRDS("~/bartMachine_version1.2.5.0.rda")
summary(bart_machine)

bartMachine v1.2.5.1 for regression

training data n = 200 and p = 5
built in 0.8 secs on 1 core, 50 trees, 250 burn-in and 1000 post. samples
Error in .jcall(bart_machine$java_bart_machine, "[D", "getGibbsSamplesSigsqs") :
RcallMethod: attempt to call a method of a NULL object.

y_hat = predict(bart_machine, X)

Error in check_serialization(object) :
This bartMachine object was loaded from an R image but was not serialized.
Please build bartMachine using the option "serialize = TRUE" next time.

Yes, this is what I am currently doing.

Does it mean that any object created by bartMachine prior to version 1.2.5.1 won't be read by upcoming versions?

Get the older version from github. Sorry this is annoying...

On Tue, Aug 25, 2020, 01:31 Pascal Oettli @.***> wrote: I use bartMachine together with caret. As recommended, I always turn the option serialize to TRUE in train. However, I noticed that bartMachine v1.2.5.1 is not able to use model created by bartMachine v1.2.5.0. I receive the following error message: Error in check_serialization(object) : This bartMachine object was loaded from an R image but was not serialized. Please build bartMachine using the option "serialize = TRUE" next time. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#31>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFAV6CAIYSZFICQN5QGMILSCNEERANCNFSM4QKHTSEA .

I believe I cannot guarantee backwards compatibility. I'm sorry.