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

David Winsemius dw|n@em|u@ @end|ng |rom comc@@t@net
Sun Dec 22 18:23:29 CET 2019


You need to read the Posting Guide (and study the options of the gmail 
interface). This is a plain text mailing list and the server does not 
accept attachments that are anything other than .txt or .pdf files.


-- 

David.

On 12/22/19 9:15 AM, Neha gupta wrote:
> 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]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list