0
$\begingroup$

all,

i am using xgboost for binary classfication. I have infs and -infs in my data due to the fact i am calcaulting ratios from one col and and another e.g. df[col1]/df[col2] , since i have zeros and nans in these columns it leads to me gettings infs, -infs, and nans.

I know xgboost can handle nan values but if i replace the infs with a very large number e.g. 99999 or -99999 for -inf, is this an issue for xgboost? my understanding is that tree based methods for classification are unaffected by 'outliers'/inf values .

what would be best method to handle these?

$\endgroup$
0
$\begingroup$

Since (most) tree-based methods only care about the ordering of values in each feature, replacing your infinite values with very large values (larger than any finite value of the feature) is fine. Of course, you'll have to do some thinking of whether df[col1]/df[col2] should actually be treated as $\pm$inf when col2 is zero, and nans can just be left in for xgboost.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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