I have tried using both 'case.weights' and 'weights' in my train(), but no matter how I write it up, I cant get it to work.
Which syntax do I have to use? Let's say I want the "dead" cases to be weighted 2:1 to my "alive cases".
Thank you so much for your reply, but I still cant get it to work, even if I copy directly from your code.
I keep getting an error saying "variable lengths differ (found for '(weights)')".
I also found an old post from github from ´16(https://github.com/topepo/caret/issues/414), where i believe the solution you suggested would be
mod <- train(Species ~ ., method = "ranger", data = iris, weights = (1:100)/100)
But I get the same error message. Do you know how to fix the error?
I figured out the problem, but I am still searching for a solution. The reason I am using caret is because I want to be able to use upsample my minority class during crossvalidation and not before, to avoid an overoptimistic model.
I figured out how to use the weights statement, like so:
but it doesn't seem to work, when I also use upsampling during CV, because then the length of my model_weights and the number of samples are no longer the same. (i get the same error message as before).
Does anyone know wether or not there is a workaround on this, so the two (upsampling + weights) can work together?