lightgbm 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/lightgbm/booster.rb +28 -0
- data/lib/lightgbm/dataset.rb +12 -0
- data/lib/lightgbm/ffi.rb +1 -0
- data/lib/lightgbm/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec446571f84421dcaf4d9453dce40aabdd8e76534e263b8de52566efc1d94560
|
4
|
+
data.tar.gz: 4be2791d0753e1f8848581c84c80c8952aa131e3eb33435293b37beee963ae19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03317e8af302bfbe6d3cd6b5d9499696c249bcfadaa0d265ca04cbd4b0d5801a1379cefc6789b1d0ad7e4d3ef1e2f9f3728f3654195823b55821b226141e41e8
|
7
|
+
data.tar.gz: b94edee304531f64a605785a707fdc4ae3b1d7879a121d98708ce5f32eef747d483f396e6a164f3fad76e0d0dcb63b46a05f68fa7fb57f3d7c6c2e1070ecabbe
|
data/CHANGELOG.md
CHANGED
data/lib/lightgbm/booster.rb
CHANGED
@@ -76,6 +76,26 @@ module LightGBM
|
|
76
76
|
out_result.read_array_of_double(num_feature).map(&:to_i)
|
77
77
|
end
|
78
78
|
|
79
|
+
def feature_name
|
80
|
+
len = self.num_feature
|
81
|
+
out_len = ::FFI::MemoryPointer.new(:size_t)
|
82
|
+
buffer_len = 255
|
83
|
+
out_buffer_len = ::FFI::MemoryPointer.new(:size_t)
|
84
|
+
out_strs = ::FFI::MemoryPointer.new(:pointer, num_feature)
|
85
|
+
str_ptrs = len.times.map { ::FFI::MemoryPointer.new(:char, buffer_len) }
|
86
|
+
out_strs.write_array_of_pointer(str_ptrs)
|
87
|
+
check_result FFI.LGBM_BoosterGetFeatureNames(handle_pointer, len, out_len, buffer_len, out_buffer_len, out_strs)
|
88
|
+
|
89
|
+
actual_len = out_buffer_len.read(:size_t)
|
90
|
+
if actual_len > buffer_len
|
91
|
+
str_ptrs = len.times.map { ::FFI::MemoryPointer.new(:char, actual_len) }
|
92
|
+
out_strs.write_array_of_pointer(str_ptrs)
|
93
|
+
check_result FFI.LGBM_BoosterGetFeatureNames(handle_pointer, len, out_len, actual_len, out_buffer_len, out_strs)
|
94
|
+
end
|
95
|
+
|
96
|
+
str_ptrs[0, out_len.read(:size_t)].map(&:read_string)
|
97
|
+
end
|
98
|
+
|
79
99
|
def model_from_string(model_str)
|
80
100
|
out_num_iterations = ::FFI::MemoryPointer.new(:int)
|
81
101
|
check_result FFI.LGBM_BoosterLoadModelFromString(model_str, out_num_iterations, @handle)
|
@@ -185,6 +205,14 @@ module LightGBM
|
|
185
205
|
str_ptrs = eval_counts.times.map { ::FFI::MemoryPointer.new(:char, buffer_len) }
|
186
206
|
out_strs.write_array_of_pointer(str_ptrs)
|
187
207
|
check_result FFI.LGBM_BoosterGetEvalNames(handle_pointer, eval_counts, out_len, buffer_len, out_buffer_len, out_strs)
|
208
|
+
|
209
|
+
actual_len = out_buffer_len.read(:size_t)
|
210
|
+
if actual_len > buffer_len
|
211
|
+
str_ptrs = eval_counts.times.map { ::FFI::MemoryPointer.new(:char, actual_len) }
|
212
|
+
out_strs.write_array_of_pointer(str_ptrs)
|
213
|
+
check_result FFI.LGBM_BoosterGetEvalNames(handle_pointer, eval_counts, out_len, actual_len, out_buffer_len, out_strs)
|
214
|
+
end
|
215
|
+
|
188
216
|
str_ptrs.map(&:read_string)
|
189
217
|
end
|
190
218
|
|
data/lib/lightgbm/dataset.rb
CHANGED
@@ -34,6 +34,18 @@ module LightGBM
|
|
34
34
|
str_ptrs = len.times.map { ::FFI::MemoryPointer.new(:char, buffer_len) }
|
35
35
|
out_strs.write_array_of_pointer(str_ptrs)
|
36
36
|
check_result FFI.LGBM_DatasetGetFeatureNames(handle_pointer, len, num_feature_names, buffer_len, out_buffer_len, out_strs)
|
37
|
+
|
38
|
+
num_features = num_feature_names.read_int
|
39
|
+
actual_len = out_buffer_len.read(:size_t)
|
40
|
+
if num_features > len || actual_len > buffer_len
|
41
|
+
out_strs = ::FFI::MemoryPointer.new(:pointer, num_features) if num_features > len
|
42
|
+
str_ptrs = num_features.times.map { ::FFI::MemoryPointer.new(:char, actual_len) }
|
43
|
+
out_strs.write_array_of_pointer(str_ptrs)
|
44
|
+
check_result FFI.LGBM_DatasetGetFeatureNames(handle_pointer, num_features, num_feature_names, actual_len, out_buffer_len, out_strs)
|
45
|
+
end
|
46
|
+
|
47
|
+
# should be the same, but get number of features
|
48
|
+
# from most recent call (instead of num_features)
|
37
49
|
str_ptrs[0, num_feature_names.read_int].map(&:read_string)
|
38
50
|
end
|
39
51
|
|
data/lib/lightgbm/ffi.rb
CHANGED
@@ -45,6 +45,7 @@ module LightGBM
|
|
45
45
|
attach_function :LGBM_BoosterNumberOfTotalModel, %i[pointer pointer], :int
|
46
46
|
attach_function :LGBM_BoosterGetEvalCounts, %i[pointer pointer], :int
|
47
47
|
attach_function :LGBM_BoosterGetEvalNames, %i[pointer int pointer size_t pointer pointer], :int
|
48
|
+
attach_function :LGBM_BoosterGetFeatureNames, %i[pointer int pointer size_t pointer pointer], :int
|
48
49
|
attach_function :LGBM_BoosterGetNumFeature, %i[pointer pointer], :int
|
49
50
|
attach_function :LGBM_BoosterGetEval, %i[pointer int pointer pointer], :int
|
50
51
|
attach_function :LGBM_BoosterPredictForMat, %i[pointer pointer int int32 int32 int int int int string pointer pointer], :int
|
data/lib/lightgbm/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lightgbm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|