有没有可能在此代码(agaricus数据集)中获得“ rmse”的方法?

时间:2018-11-24 14:32:55

标签: r r-caret

我想在此代码中获得rmse,但是我唯一能做的就是二进制分类,这意味着我无法获得rmse,因为在进行回归时它是度量标准的。这是可复制的代码。

library(caret)
library(xgboost)

data(agaricus.train, package = "xgboost")
data(agaricus.test, package = "xgboost")
train<- agaricus.train
test<- agaricus.test

#####################Train Model############################
train$label <- ifelse(train$label == 0, "no", "yes") #convert target to character or factor

xgb_grid_1 <- expand.grid(
  nrounds = c(2:5),
  eta = seq(0,1,0.2),
  max_depth = c(2:5),
  gamma = seq(0,1,0.2),
  colsample_bytree = 1,
  min_child_weight = 1,
  subsample = 1
)

xgb_trcontrol_1 <- trainControl(
  method = "cv",                
  number = 5,                   
  verboseIter = TRUE,           
  returnData = FALSE,          
  returnResamp = "all",         

  classProbs = TRUE,            

  summaryFunction = twoClassSummary  # I need to change this line to get regression socre
)



xgb_train1 <- caret::train(
  x = as.matrix(train$data),
  y = train$label,
  trControl = xgb_trcontrol_1,
  tuneGrid  = xgb_grid_1,
  metric = "ROC",    # I want to get rmse instead of ROC
  method = "xgbTree"
)  

在这段代码中我应该怎么做才能获得rmse?

0 个答案:

没有答案