2015-10-16 76 views
4

我想使用Caret提供的一個未包含的軟件包,並且遇到一個我無法弄清楚的錯誤,有什麼想法?我用following link上手在火車上使用自己的模型(插入符號包)?

bmsMeth<-list(type="Regression",library="BMS",loop=NULL,prob=NULL) 
prm<-data.frame(parameter="mprior.size",class="numeric",label="mprior.size") 
bmsMeth$parameters<-prm 
bmsGrid<-function(x,y,len=NULL){ 
out<-expand.grid(mprior.size=seq(2,3,by=len)) 
out 
} 
bmsMeth$grid<-bmsGrid 
bmsFit<-function(x,y,param, lev=NULL) {bms(cbind(y,x),burn=5000,iter=100000,nmodel=1000,mcmc="bd",g="UIP",mprior.size=param$mprior.size)} 
bmsMeth$fit<-bmsFit 
bmsPred<-function(modelFit,newdata,preProcess=NULL,submodels=NULL){predict(modelFit,newdata)} 
bmsMeth$predict<-bmsPred 

library(caret) 
data.train<-data.frame(runif(100),runif(100),runif(100),runif(100),runif(100))#synthetic data for testing 
bms(cbind(data.train[,1],data.train[,-1]),burn=5000,iter=100000,nmodel=1000,mcmc="bd",g="UIP",mprior.size=2)#function out of caret is working 

preProcess=c('center','scale') 
myTimeControl <- trainControl(method = "timeslice",initialWindow = 0.99*nrow(data.train), horizon = 1, fixedWindow = FALSE) 
tune <- train(data.train[,-1],data.train[,1],preProcess=preProcess,method = bmsMeth,tuneLength=2,metric= "RMSE",trControl =myTimeControl,type="Regression") 

錯誤我得到:

錯誤train.default(data.train [,-1],data.train [1],預處理= prerior::Stopping此外:警告消息:1:在 eval(expr,envir,enclos):模型適合Training1失敗: mprior.size = 2方法$ fit中出錯(x = x,y = y,wts = wts,param = tuneValue,lev = obsLevels,:未使用的參數(wts = wts,last = last,classProbs = classProbs,type =「Regression」)

2:在nominalTrainWorkflow中(x = x,y = y,wts =權重,info = )trainInfo,:在重採樣性能 度量中存在缺失值。

+0

爲目的在尋找解決方案時,我認爲要搜索的確切英文文本是「嘗試應用非功能」。 – eipi10

+0

感謝您的版本! –

+0

你可以讓你的問題在一個小例子中重現嗎? –

回答

3

Apparantly,我不得不將這些參數的功能,即使我從來沒有使用它們:

bmsFit<-function(x,y,param, lev=NULL, last, weights, classProbs, ...) {bms(data.frame(y,x),burn=5000,iter=100000,nmodel=1000,mcmc="bd",g="UIP",mprior.size=param$mprior.size)} 
0

你的函數BMS()似乎不存在......

+0

你可以在圖書館(BMS)找到它 –