[R] all the MAE metric values are missing (Error message)

Neha gupta neh@@bo|ogn@90 @end|ng |rom gm@||@com
Sun Dec 22 18:15:56 CET 2019


I am using the following code to tune the 4 parameters of Gradient Boosting
algorithm using Simulated annealing (optim). When I run the program, after
few seconds it stops and displays the following error:

I point out here that the same code works for RF ( mtry parameter) and SVM
(cost and sigma parameters). So, I guess the problem should be in the 4
parameters of GBM

Something is wrong; all the MAE metric values are missing:
      RMSE        Rsquared        MAE
 Min.   : NA   Min.   : NA   Min.   : NA
 1st Qu.: NA   1st Qu.: NA   1st Qu.: NA
 Median : NA   Median : NA   Median : NA
 Mean   :NaN   Mean   :NaN   Mean   :NaN
 3rd Qu.: NA   3rd Qu.: NA   3rd Qu.: NA
 Max.   : NA   Max.   : NA   Max.   : NA
 NA's   :1     NA's   :1     NA's   :1

Code is here/// If you need the  dataset, I can attach in the email

d=readARFF("dat.arff")   ///DATA IS REGRESSION BASED

index <- createDataPartition(log10(d$Price), p = .70,list = FALSE)
tr <- d[index, ]
ts <- d[-index, ]

index_2 <- createFolds(log10(tr$Price), returnTrain = TRUE, list = TRUE)
ctrl <- trainControl(method = "cv", index = index_2)

obj <- function(param, maximize = FALSE) {
  mod <- train(log10(Price) ~ ., data = tr,
               method = "gbm",
               preProc = c("center", "scale", "zv"),
               metric = "MAE",
               trControl = ctrl,
       //HERE IN tuneGrid WHEN I USE PARAMETERS FOR SVM    AND RF, IT
WORKS, BUT FOR GBM, IT DOES NOT WORK

               tuneGrid = data.frame(n.trees = 10^(param[1]),
interaction.depth = 10^(param[2]),
                                     shrinkage=10^(param[3]),
n.minobsinnode=10^(param[4])))

  if(maximize)
    -getTrainPerf(mod)[, "TrainMAE"] else
      getTrainPerf(mod)[, "TrainMAE"]
}
num_mods <- 50

## Simulated annealing from base R

/// I JUST USED HERE SOME INITIAL POINTS OF THE 4 PARAMETERS OF GBM

san_res <- optim(par = c(10,1,0.1,1), fn = obj, method = "SANN",
                 control = list(maxit = num_mods))
san_res

	[[alternative HTML version deleted]]



More information about the R-help mailing list