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
LightGBM inference result matches input type #2129
Conversation
ByteBuffer bb = ByteBuffer.allocateDirect(length * 4); | ||
FloatBuffer wrapped = bb.asFloatBuffer(); | ||
for (int i = 0; i < length; i++) { | ||
wrapped.put((float) lightgbmlib.doubleArray_getitem(outBuffer, i)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we call lightgbm.floatArray_getitem()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behavior of the lightgbm engine is to always return a double array and this is the utility provided by lightgbm to get from a JNI double[]
data structure. So if we want to return a float[], we need to convert it from double to float
This makes the LightGBM inference return the same as the input type (either float32 or float64) rather than always returning float64 per the API. In addition, it adds a bit nicer handling for creation from a Buffer in that it will also accept either a FloatBuffer or a DoubleBuffer.
Codecov ReportBase: 72.08% // Head: 71.49% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #2129 +/- ##
============================================
- Coverage 72.08% 71.49% -0.60%
- Complexity 5126 6315 +1189
============================================
Files 473 624 +151
Lines 21970 27871 +5901
Branches 2351 3009 +658
============================================
+ Hits 15838 19927 +4089
- Misses 4925 6480 +1555
- Partials 1207 1464 +257
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
This makes the LightGBM inference return the same as the input type (either float32 or float64) rather than always returning float64 per the API. In addition, it adds a bit nicer handling for creation from a Buffer in that it will also accept either a FloatBuffer or a DoubleBuffer.
This makes the LightGBM inference return the same as the input type (either float32 or float64) rather than always returning float64 per the API.
In addition, it adds a bit nicer handling for creation from a Buffer in that it will also accept either a FloatBuffer or a DoubleBuffer.