-
Notifications
You must be signed in to change notification settings - Fork 636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add case weights to summary function #1
Comments
Resolved (and test cases added) as of caret version 6.0-29 |
Hi, I am using caret 6.0-58, But still not able to use a custom summary function. My Code and error as below - mymetric <- function(predictions, target, weights){ number = 10 tglm = train( x = wip[,c(basef,retf_p1)] , y = wip$Ret_2, method = "glm", weights = wip$Weight_Intraday, trControl = tc) Error in FUN(left, right) : non-numeric argument to binary operator I have supplied the weights while specifying the train function. Pls let me know if there is mistake in the call. I also tried the same with changing the column names of the function to match to the data column names as this - But it still failed. Thanks, |
The (lack of) details are here. Basically, when the summary function us called, there is a data frame called
Your summary function can use this weight column for its calculations. Please note that not all R model functions can use case weights so if you want to use a column of your data for case weights, you will have to look at the underlying model function using |
The original request is from here. This is the request:
I'm using R's caret package to do some grid search and model evaluation. I have a custom evaluation metric that is a weighted average of absolute error. Weights are assigned at the observation level.
Here an example is given on how to use summaryFunction to define a custom evaluation metric for caret's train().
To quote:
The trainControl function has a argument called summaryFunction that specifies a function for computing performance. The function should have these arguments:
I cannot quite figure out how to pass the observation weights to summaryFunction.
The text was updated successfully, but these errors were encountered: