Closed StevenWhitaker closed 11 months ago
Yikes, that must have been confusing. libxgboost
returns a pointer to us on predict
and apparently it is using the same memory location, which is clearly not something we considered when writing this wrapper.
The only way around this, unfortunately, is to copy the entire output array, but it seems pretty obvious that that should be the default behavior, and it's implemented in #188.
In that PR I have added the (unexported) function predict_nocopy
for users who don't want the extra allocation.
Awesome, thanks for the quick fix! And your fix was exactly my work-around: just copy
.
It did take me a good hour or so to figure out why my results looked funny, but I'm glad I was able to track it down and hopefully prevent headache for someone else down the line.
I don't know if this is a bug or a feature, or if I'm doing something wrong, but
predict
overwrites resultspredict
returned previously.MWE:
In particular, note that the first 5 elements of
pred
are overwritten by the second call topredict
. I don't know if this behavior is specific to the objective and/or eval metric I used or if it is more general.