0
$\begingroup$

I have an highly imbalanced dataset where very few y values are 'out of norm'. I want to predict as close as possible to these 'out of norm' values for those observations. For this I am trying to create a custom loss function for my XGBRegressor model where I put more weight on the contribution of 'out of norm' values in the loss function of the model.

All the samples will have different weights. I don't understand how to use the test sample weights in prediction?

$\endgroup$
2
  • $\begingroup$ What do you mean with "out of norm"? $\endgroup$
    – Gijs
    Nov 15, 2021 at 8:10
  • $\begingroup$ 'out of norm'=outliers. But I dont want to discard them. $\endgroup$
    – user340737
    Nov 15, 2021 at 8:33

1 Answer 1

0
$\begingroup$

You can use a squared error loss function for XGBRegressor, which is the default often. A squared error will weigh heavily any outliers in your dataset. This is also the reason people will typically try to get rid of the outliers, because they such a big influence on the final result. If you want to emphasize them even more I guess you can go with a cubic loss.

$\endgroup$
1
  • $\begingroup$ Sorry, i should have mentioned before but I did try with squared error loss function before, but the predictions for the outliers were way off. Hence was thinking to customize the loss function. The outliers are kind of important for my dataset and i want to predict them more accurately. $\endgroup$
    – user340737
    Nov 15, 2021 at 9:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.