[R] How to get Mean Magnitude of Relative Error with caret library

Neha gupta neh@@bo|ogn@90 @end|ng |rom gm@||@com
Sun Jan 10 20:57:05 CET 2021


Hi, I am using caret package and using nested resampling method (i.e. 5
fold for outer fold). I am getting the RMSE and MAE values, which are
default to the caret library.
My question is how can we implement the Mean Magnitude of Relative Error
(MRE and MMRE) with caret. My code is the following:

outer_folds <- createFolds(d$price, k = 5)
boot <- trainControl(method = "boot", number=100)

CV1 <- lapply(outer_folds, function(index){
  tr <- d[-index, ]
  ts <- d[index,]

  cart1 <- train(bug ~ ., data = tr,
                  method = "rf",
                 metric = "MAE",
                 preProc = c("center", "scale", "nzv"),
                 trControl = boot)

  postResample(predict(cart1, ts), ts$price)
})
sapply(CV1, function(x) x[3]) -> CV_MAE1
CV_MAE1

	[[alternative HTML version deleted]]



More information about the R-help mailing list