Hello,
Please cc the list.
Yes, I believe so, it's hard to say, the code is not reproducible.
But that's what the docs say. Why not try it?
Hope this helps,
Rui Barradas
Às 16:00 de 24/02/20, javed khan escreveu:
Thanks for your feedback Rui.. It means I have to specify the "mod" in
the resamples (based on the code below) instead of ga_res? mod here is
the train function of caret?
resamples(list( First_data= mod, Second_data=mod2)
My sample code is here
obj <- function(param, maximize = FALSE) {
print(param)
mod <- train(Result ~ ., data = tr,
method = "gbm",
metric = "MAE",
trControl = ctrl
tuneGrid = data.frame(n.trees =
(param[1]), interaction.depth = (param[2]),
shrinkage=(param[3]),
n.minobsinnode=(param[4])))
if(maximize)
-getTrainPerf(mod)[, "TrainMAE"] else
getTrainPerf(mod)[, "TrainMAE"]
}
Then GA function
library(GA)
set.seed(45642)
ga_res <- ga(type = "real-valued",
fitness = svm_obj,
min = c(0.5,0), max = c(1,1),
maxiter = ceiling(num_mods),
maximize = TRUE)
ga_res@solution
On Mon, Feb 24, 2020 at 2:03 PM Rui Barradas <ruipbarra...@sapo.pt
<mailto:ruipbarra...@sapo.pt>> wrote:
Hello,
If you are using function resamples from package caret, just read its
help page. From ?resamples, section Arguments:
Arguments
x
a list of two or more objects of class train, sbf or rfe with a common
set of resampling indices in the control object. For sort.resamples, it
is an object generated by resamples.
Your x argument is not an object of one of those classes. You are
passing the function a list of 2 numeric values, not an object
resembling the examples in that help page.
Hope this helps,
Rui Barradas
Às 11:35 de 24/02/20, javed khan escreveu:
> Hello
>
> I am using genetic algorithm for some optimization problem. I
executed it
> with 2 types of data and get results like
>
> GA=40
> GA2=60
>
> When I combine it with resamples
>
> Value=resamples (list (GA, GA2))
>
> It gives me the error
>
> $ operator is invalid for atomic vectors.
>
> What should be the issue here?
>
> Thanks
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org <mailto:R-help@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.
>
______________________________________________
R-help@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.