« Return to Thread: Calling a stored model within the predict() function

Calling a stored model within the predict() function

by Jim_S :: Rate this Message:

Reply to Author | View in Thread

Hi all,

First of all, I'm a novice R user (less that a week), so perhaps my code isn't very efficient.

Using the MBoost package I created a model:

model <- gamboost(fpfm,data=SampleClusterData,baselearner="bbs") # Creating a model
save(model,file="model.RData") # Saving a model


After this, during a new R session, I want to deploy this model:

setwd("Q:/Program Files/R/library/mboost/data")
NewData <- read.table("NewData.txt",header=TRUE,sep=",") #Calling a new data set
setwd("Q:/Program Files/R/library/mboost")
model <- load("model.rdata") # Loading the model

This won't work. When I check the content of the 'model' object, the only screen output I see is :

"model
[1]model"

...and that the actual file size from 'model.rdata' is exactly 4,100 kb (is this a limit?!)


Then I try to call this model object with the predict() function:

CRPredict <- predict(model, newdata= NewData) # Make the predictions

This results in the following error message:

"Error in UseMethod("predict") : no applicable method for "predict"  "

Is there a correct way to store and call a model or is it only possible to create & deploy a model during the same R session?

Thanks!

Jim


 « Return to Thread: Calling a stored model within the predict() function