Closed SixiangHu closed 8 years ago
modelMea <- function(act,pred){
#Mean square error
mse <- function(pred,act){
mean( (pred-act)^2 , na.rm = TRUE )
}
#Mean absolute error
mae <- function(pred,act)
{
mean(abs(act-pred), na.rm = TRUE )
}
MM_mse <- as.numeric(as.matrix(unlist(lapply(pred,mse,act=act))))
MM_mae <- as.numeric(as.matrix(unlist(lapply(pred,mae,act=act))))
res <- data.frame(MSE = MM_mse,RMSE = sqrt(MM_mse),
MAE = MM_mae,RMAE = sqrt(MM_mae))
rownames(res) <- names(pred)
t(res)
}
Or, just use the resamples
function in caret