Skip to content

Commit

Permalink
Removed unneeded code [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Nov 13, 2024
1 parent a030213 commit 0de57e5
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions lib/lightgbm/booster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def dump_model(num_iteration: nil, start_iteration: 0)
out_str = ::FFI::MemoryPointer.new(:char, buffer_len)
feature_importance_type = 0 # TODO add option
check_result FFI.LGBM_BoosterDumpModel(handle_pointer, start_iteration, num_iteration, feature_importance_type, buffer_len, out_len, out_str)
actual_len = read_int64(out_len)
actual_len = out_len.read_int64
if actual_len > buffer_len
out_str = ::FFI::MemoryPointer.new(:char, actual_len)
check_result FFI.LGBM_BoosterDumpModel(handle_pointer, start_iteration, num_iteration, feature_importance_type, actual_len, out_len, out_str)
Expand Down Expand Up @@ -110,7 +110,7 @@ def model_to_string(num_iteration: nil, start_iteration: 0)
out_str = ::FFI::MemoryPointer.new(:char, buffer_len)
feature_importance_type = 0 # TODO add option
check_result FFI.LGBM_BoosterSaveModelToString(handle_pointer, start_iteration, num_iteration, feature_importance_type, buffer_len, out_len, out_str)
actual_len = read_int64(out_len)
actual_len = out_len.read_int64
if actual_len > buffer_len
out_str = ::FFI::MemoryPointer.new(:char, actual_len)
check_result FFI.LGBM_BoosterSaveModelToString(handle_pointer, start_iteration, num_iteration, feature_importance_type, actual_len, out_len, out_str)
Expand Down Expand Up @@ -168,7 +168,7 @@ def predict(input, start_iteration: nil, num_iteration: nil, **params)
out_len = ::FFI::MemoryPointer.new(:int64)
out_result = ::FFI::MemoryPointer.new(:double, num_class * input.count)
check_result FFI.LGBM_BoosterPredictForMat(handle_pointer, data, 1, input.count, input.first.count, 1, 0, start_iteration, num_iteration, params_str(params), out_len, out_result)
out = out_result.read_array_of_double(read_int64(out_len))
out = out_result.read_array_of_double(out_len.read_int64)
out = out.each_slice(num_class).to_a if num_class > 1

singular ? out.first : out
Expand Down Expand Up @@ -244,11 +244,6 @@ def num_class
out.read_int
end

# read_int64 not available on JRuby
def read_int64(ptr)
ptr.read_array_of_int64(1).first
end

def sorted_feature_values(input_hash)
input_hash.transform_keys(&:to_s).fetch_values(*cached_feature_name)
end
Expand Down

0 comments on commit 0de57e5

Please sign in to comment.