 # Weighted RMSE Validity with XGBoost

Hi,

I have a problem where the target (labels) takes a distribution as [-0.54 : 0.54] and I would like to penalize more the extreme in this regression problem. One idea that was to use customize a custom loss function and passing it onto the feval.

I’m using R and I’ve come up with the idea of using a weighted RMSE where a higher weight is applied to the extreme (higher than 0.53 and below -0.53). A few questions come in mind knowing some challenges with optimization problems.

Does the use of conditions (if statements) to apply a higher weight (2 for extreme vs. 1) can create problems in the way xgboost minimize this function?

Moreover, let me know if you have any suggestion that can solve the problems at hands (caring more about some segment of a specific distribution than the others).

wRMSE <- function(preds, dtrain) {
labels <- getinfo(dtrain, “label”)
err <- sqrt(sum((preds-labels)^2*
(ifelse(labels > 0.53,2,ifelse(labels < -0.53,2,1))/
sum(ifelse(labels > 0.53,2,ifelse(labels < -0.53,2,1))))))
return(list(metric = “wRMSE”, value = err))

Thanks