komiya-atsushi / xgboost-predictor-java

Pure Java implementation of XGBoost predictor for online prediction tasks.
Apache License 2.0
339 stars 108 forks source link

How to treat the missing values? #6

Closed xdwangh closed 7 years ago

xdwangh commented 8 years ago

I trained model by xgboost with missing value. I don't know how to treat missing value in this tools

xdwangh commented 8 years ago

I found that I can set missing value as zero in file "FVec.java". However, some feature values actually are zeros.

komiya-atsushi commented 8 years ago

@xdwangh

You can represent missing values using Float.NaN or Double.NaN.

double[] featureValues = {
        1.0,
        Float.NaN, // missing value
        0.0,
        // ...
};

FVec fv = FVec.Transformer.fromArray(featureValues, false /* = do not treats zero as missing value */);