lib/xgb/booster.rb in xgb-0.1.2 vs lib/xgb/booster.rb in xgb-0.1.3
- old
+ new
@@ -51,11 +51,11 @@
def predict(data, ntree_limit: nil)
ntree_limit ||= 0
out_len = ::FFI::MemoryPointer.new(:uint64)
out_result = ::FFI::MemoryPointer.new(:pointer)
check_result FFI.XGBoosterPredict(handle_pointer, data.handle_pointer, 0, ntree_limit, out_len, out_result)
- out = out_result.read_pointer.read_array_of_float(out_len.read_uint64)
+ out = out_result.read_pointer.read_array_of_float(read_uint64(out_len))
num_class = out.size / data.num_row
out = out.each_slice(num_class).to_a if num_class > 1
out
end
@@ -66,10 +66,10 @@
# returns an array of strings
def dump(fmap: "", with_stats: false, dump_format: "text")
out_len = ::FFI::MemoryPointer.new(:uint64)
out_result = ::FFI::MemoryPointer.new(:pointer)
check_result FFI.XGBoosterDumpModelEx(handle_pointer, fmap, with_stats ? 1 : 0, dump_format, out_len, out_result)
- out_result.read_pointer.get_array_of_string(0, out_len.read_uint64)
+ out_result.read_pointer.get_array_of_string(0, read_uint64(out_len))
end
def dump_model(fout, fmap: "", with_stats: false, dump_format: "text")
ret = dump(fmap: fmap, with_stats: with_stats, dump_format: dump_format)
File.open(fout, "wb") do |f|