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 using the following command and saved it to a file for later use: 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= SampleClusterData) # Make the predictions This results in the following error message: "Error in UseMethod("predict") : no applicable method for "predict" " Is the 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 -- View this message in context: http://www.nabble.com/Calling-a-stored-model-within-the-predict%28%29-function-tp16918111p16918111.html Sent from the R help mailing list archive at Nabble.com.
No replies yet... Is my problem explanation unclear? Please let me know, thanks! Jim -- View this message in context: http://www.nabble.com/Calling-a-stored-model-within-the-predict%28%29-function-tp16918111p16923325.html Sent from the R help mailing list archive at Nabble.com.
Gabor Grothendieck
2008-Apr-27 12:39 UTC
[R] Calling a stored model within the predict() function
Read the last line of every message to r-help. On Sat, Apr 26, 2008 at 7:14 PM, Jim_S <virtualreal at gmail.com> wrote:> > 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 using the following command and > saved it to a file for later use: > > 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= SampleClusterData) # Make the > predictions > > This results in the following error message: > > "Error in UseMethod("predict") : no applicable method for "predict" " > > Is the 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 > > > > -- > View this message in context: http://www.nabble.com/Calling-a-stored-model-within-the-predict%28%29-function-tp16918111p16918111.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >