Description Usage Arguments Value Author(s) Examples
Weighted average and standard deviation of multiple models. The weights can be the model's performance metrics such as R2 or RMSE.
1 |
pPath |
Path for the prediction files from multiple models with the unified format and field names. File format: CSV with head. |
mFile |
File path for the corresponding multiple models's performance. CSV format:mid, r2, rmse. |
metrF |
target metric such as rmse or r2 to weigh the model's output |
preF |
prediction field name |
idF |
unique identifier string |
dateF |
date string if any |
id and corresponding mean and standard deviation. Format: dataframe
Lianfa Li: lspatial@gmail.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #First generate the prediction dataset and metrics.
# In application, you can use parSpModel to train models and
# get the models's performance metrics, and use the parATimePredict function to make the prediction
# Simulared data
dPath=tempdir()
pPath=paste(dPath,"/preds",sep="")
unlink(pPath, recursive=TRUE, force=TRUE)
dir.create(pPath)
nr=2000;nmod=80
for(i in c(1:nmod)){ # i =1
dset=data.frame(gid=c(1:nr),rid=sample(c(1:30),size=nr,replace=TRUE),stringsAsFactors = FALSE)
dset$pre=dset$gid%%nmod+rnorm(nr,mean=5,sd=9)+runif(nr,0,1)
dset$gid=paste("c",dset$gid,sep="")
afile=paste(pPath,"/m",i,".csv",sep="")
write.csv(dset,file=afile,row.names = FALSE)
}
modelsMetrics=data.frame(mid=c(1:nmod),r2=runif(nmod,0.6,0.9),rmse=runif(nmod,20,60))
mfile=paste(dPath,"/model_metrics.csv",sep="")
write.csv(modelsMetrics,file=mfile,row.names = FALSE)
result=weiA2Ens(pPath,mfile,metrF="rmse","pre","gid","gid")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.