xgboost icon indicating copy to clipboard operation
xgboost copied to clipboard

what "xgboost missing = nan " means

Open tngks66 opened this issue 10 years ago • 9 comments

i don`t know that when i set xgboost(data, label, para, missing = nan) , what missing = nan means. just missing = nan means that filling NA into the NAN? or filling empty valu into the NAN?

tngks66 avatar Feb 14 '16 05:02 tngks66

You specify your nan value this way. Let's say you did something like data.fillna(-999), then missing = -999 would be correct.

Far0n avatar Feb 14 '16 11:02 Far0n

so you mean that if i set the missing= 100, NA fills in 1000?

tngks66 avatar Feb 14 '16 14:02 tngks66

No, xgb does not change the data at all. It just treats the specified missing value as a special one.

Far0n avatar Feb 14 '16 15:02 Far0n

hmm.... could you please make concrete the special one? i don`t understand

tngks66 avatar Feb 14 '16 15:02 tngks66

is it means that missing = nan is treating NA to nan ? no fill in nan?

tngks66 avatar Feb 14 '16 15:02 tngks66

Let's say you have the following numpy array: data = [1,2, np.nan, 4]. Xgb will complain about the np.nan within that array if you call DMatrix(data). So, what you do is replacing np.nan by an arbitrary value, let's say "-999". Hence data becomes: data_new = [1,2, -999, 4]. Now you tell xgb, that you encoded missing values by "-999": DMatrix(data_new, missing=-999).

Far0n avatar Feb 14 '16 15:02 Far0n

sorry for my ignorance... i dont know np.nan and numpy array ... Im R user

tngks66 avatar Feb 14 '16 15:02 tngks66

@tngks66 So say you data has 99999, which in real life means this data is missing for your problem, if you set missing = 99999, xgb will treat this special value as missing value. It will treat 99999 as NA.

terrytangyuan avatar Feb 17 '16 22:02 terrytangyuan

good explains

qianrenliang avatar Aug 03 '17 07:08 qianrenliang