SixiangHu / DataMan

R package for data cleaning, preliminary data analysis and modeling assessing with visualisation.
3 stars 0 forks source link

Summary of statistics about models #34

Closed SixiangHu closed 8 years ago

SixiangHu commented 8 years ago
SixiangHu commented 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)
}
SixiangHu commented 8 years ago

Or, just use the resamples function in caret