-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
java predict results are different from python predict results by loading the same model #11221
Comments
Thank you for sharing, will look into it. Initial guess is there's floating point error and one of the values is quite close to the split value. Python is using f64 while java is using f32. Any chance you can share the model for reproducing the issue? |
Thanks for looking into the issue.
|
Hello, In Java, the default value is 0 in all cases except for two specific places. @trivialfis could you please review this PR to change the default value to NaN as well ? It makes more sense than 0 and improves consistency across bindings. |
@ayoub317
|
We used python code to train xgb model, and then used java to load the model and do predictions.
We observed that java predict results are quite different from python results by loading the same model.
python version
Java version:
Same 2.1.4 version were used in python and java code.
Here are the code to reproduce the issue.
We used python to train xgb model, and then load the model, make two predictions.
One prediction used customized float array, and the other prediction used the continued array from 0 to 228.
Output:
In java code, we load the same model, and also made two predictions.
One prediction used the same float array, and the other used the same continued array from 0 to 228.
We found out prediction 1 is quite different from python code to java code, while perdiction 2 are exactly the same.
Output:
We've no ideas why prediction result 1 is quite different.
The text was updated successfully, but these errors were encountered: