如何从GA超参数调整中获得RMSE值?

时间:2019-11-11 20:53:05

标签: r hyperparameters

我找到了使用GA进行超参数调整的R代码。以下是代码,但未显示预期结果,这将是预测准确性吗?我已经提到了问题末尾产生的输出,但是我希望输出的RMSE值例如0.44、0.23、0.1等

代码如下:

d=readARFF("soft.arff")
index <- createDataPartition(d$Effort, p = .70,list = FALSE)
tr <- d[index, ]
ts <- d[-index, ] 
svm_fit <- function(x) {
  mod <- train(Rank ~ ., data = tr,
               method = "svmRadial",
               preProc = c("center", "scale"),
               trControl = trainControl(method = "cv"),
               tuneGrid = data.frame(C = 2^x[1], sigma = exp(x[2])))
  -getTrainPerf(mod)[, "TrainRMSE"]
}

svm_ga_obj <- GA::ga(type = "real-valued", 

                            fitness = svm_fit,              

                                  min = c(-5, -5), 
                                  max = c(5, 0), 
                                  popSize = 50, 
                                  maxiter = 2,
                                  seed = 16478,
                                  keepBest = TRUE,
                                  monitor = NULL,
                                  elitism = 2)

summary(svm_ga_obj)

该代码未给出错误并成功执行,但是代替了RMSE值,当我执行summary(svm_ga_obj)时,它显示以下输出。

GA settings: 
Type                  =  real-valued 
Population size       =  50 
Number of generations =  2 
Elitism               =  2 
Crossover probability =  0.8 
Mutation probability  =  0.1 
Search domain = 
      x1 x2
lower -5 -5
upper  5  0

GA results: 
Iterations             = 2 
Fitness function value = -6309.072 
Solution = 
          x1        x2
[1,] 4.80478 -4.202595

问题出在哪里,我如何获得RMSE的价值?

0 个答案:

没有答案