lightgbm 0.1.9 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a4aac9eac1ab0dadbf31d1e1fc2714e75a8c37075538aef5c53b42df1c34f658
4
- data.tar.gz: ca3a1043c55184992b3fac611963062d01747449f6170719ef1f299d4f0474c9
3
+ metadata.gz: 2b3405aa832aaa365ce38d59bf5a36b318f8d02c1a236ea144eb9b102bf7f07e
4
+ data.tar.gz: 5be378b94486a668fffdc276a73ff62f24a24b644932bd776fd877f4b69b157a
5
5
  SHA512:
6
- metadata.gz: c2f14ccc3b40690060d2ee533cfe46e137f40e91520aab3eb188a8a03a697a6956853b717e743cd357d0a059836fc32e9e0aa0fbe5a7dd4263b1ff3e94e79601
7
- data.tar.gz: 64abdb43f4c45222dcbb39ddde1d21350b2b4958439dc84d8f13684f4e9bcd3aa2c0e49aa8fd9ae1dfc09b8bc0ce69592e95aab0542684f3c952e9e67ac4689f
6
+ metadata.gz: 914379fe9271306117fc222534915f3c19de1c6b165ecc053f49b9089da0b85594c8430958f03f28a23d98fcf2879c4948c8d3e5fecee920c2984700928380ec
7
+ data.tar.gz: 4f93ae6b4a2c3123d452ecf41d7ada8473af397f12ddafb4e34b4e552aae4b6ef23ecb75b54ce3f7f64ba0985402c6172070de4afaca2ea614875f6d91c2de1a
@@ -1,3 +1,7 @@
1
+ ## 0.2.0 (2020-08-31)
2
+
3
+ - Updated LightGBM to 3.0.0
4
+
1
5
  ## 0.1.9 (2020-06-10)
2
6
 
3
7
  - Added support for Rover
@@ -1,22 +1,22 @@
1
- Copyright (c) 2019 Andrew Kane
1
+ The MIT License (MIT)
2
2
 
3
- MIT License
3
+ Copyright (c) Microsoft Corporation
4
+ Copyright (c) 2019-2020 Andrew Kane
4
5
 
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
12
 
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
15
 
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
data/README.md CHANGED
@@ -129,7 +129,7 @@ Data can be an array of arrays
129
129
  [[1, 2, 3], [4, 5, 6]]
130
130
  ```
131
131
 
132
- Or a Numo NArray
132
+ Or a Numo array
133
133
 
134
134
  ```ruby
135
135
  Numo::NArray.cast([[1, 2, 3], [4, 5, 6]])
@@ -61,16 +61,14 @@ module LightGBM
61
61
  # print results
62
62
  messages = []
63
63
 
64
+ eval_valid = booster.eval_valid
64
65
  if valid_contain_train
65
- # not sure why reversed in output
66
- booster.eval_train.reverse.each do |res|
67
- messages << "%s's %s: %g" % [res[0], res[1], res[2]]
68
- end
66
+ eval_valid = eval_valid + booster.eval_train
69
67
  end
70
-
71
- eval_valid = booster.eval_valid
72
68
  # not sure why reversed in output
73
- eval_valid.reverse.each do |res|
69
+ eval_valid.reverse!
70
+
71
+ eval_valid.each do |res|
74
72
  messages << "%s's %s: %g" % [res[0], res[1], res[2]]
75
73
  end
76
74
 
@@ -188,8 +186,7 @@ module LightGBM
188
186
  # use best iteration from first metric if not stopped early
189
187
  best_iteration ||= best_iter[best_iter.keys.first]
190
188
  eval_hist.each_key do |k|
191
- # TODO uncomment for 0.2.0
192
- # eval_hist[k] = eval_hist[k].first(best_iteration + 1)
189
+ eval_hist[k] = eval_hist[k].first(best_iteration + 1)
193
190
  end
194
191
  end
195
192
 
@@ -39,11 +39,12 @@ module LightGBM
39
39
  buffer_len = 1 << 20
40
40
  out_len = ::FFI::MemoryPointer.new(:int64)
41
41
  out_str = ::FFI::MemoryPointer.new(:char, buffer_len)
42
- check_result FFI.LGBM_BoosterDumpModel(handle_pointer, start_iteration, num_iteration, buffer_len, out_len, out_str)
42
+ feature_importance_type = 0 # TODO add option
43
+ check_result FFI.LGBM_BoosterDumpModel(handle_pointer, start_iteration, num_iteration, feature_importance_type, buffer_len, out_len, out_str)
43
44
  actual_len = read_int64(out_len)
44
45
  if actual_len > buffer_len
45
46
  out_str = ::FFI::MemoryPointer.new(:char, actual_len)
46
- check_result FFI.LGBM_BoosterDumpModel(handle_pointer, start_iteration, num_iteration, actual_len, out_len, out_str)
47
+ check_result FFI.LGBM_BoosterDumpModel(handle_pointer, start_iteration, num_iteration, feature_importance_type, actual_len, out_len, out_str)
47
48
  end
48
49
  out_str.read_string
49
50
  end
@@ -86,11 +87,12 @@ module LightGBM
86
87
  buffer_len = 1 << 20
87
88
  out_len = ::FFI::MemoryPointer.new(:int64)
88
89
  out_str = ::FFI::MemoryPointer.new(:char, buffer_len)
89
- check_result FFI.LGBM_BoosterSaveModelToString(handle_pointer, start_iteration, num_iteration, buffer_len, out_len, out_str)
90
+ feature_importance_type = 0 # TODO add option
91
+ check_result FFI.LGBM_BoosterSaveModelToString(handle_pointer, start_iteration, num_iteration, feature_importance_type, buffer_len, out_len, out_str)
90
92
  actual_len = read_int64(out_len)
91
93
  if actual_len > buffer_len
92
94
  out_str = ::FFI::MemoryPointer.new(:char, actual_len)
93
- check_result FFI.LGBM_BoosterSaveModelToString(handle_pointer, start_iteration, num_iteration, actual_len, out_len, out_str)
95
+ check_result FFI.LGBM_BoosterSaveModelToString(handle_pointer, start_iteration, num_iteration, feature_importance_type, actual_len, out_len, out_str)
94
96
  end
95
97
  out_str.read_string
96
98
  end
@@ -115,7 +117,7 @@ module LightGBM
115
117
  end
116
118
 
117
119
  # TODO support different prediction types
118
- def predict(input, num_iteration: nil, **params)
120
+ def predict(input, start_iteration: nil, num_iteration: nil, **params)
119
121
  input =
120
122
  if daru?(input)
121
123
  input.map_rows(&:to_a)
@@ -126,6 +128,7 @@ module LightGBM
126
128
  singular = !input.first.is_a?(Array)
127
129
  input = [input] if singular
128
130
 
131
+ start_iteration ||= 0
129
132
  num_iteration ||= best_iteration
130
133
  num_class ||= num_class()
131
134
 
@@ -136,7 +139,7 @@ module LightGBM
136
139
 
137
140
  out_len = ::FFI::MemoryPointer.new(:int64)
138
141
  out_result = ::FFI::MemoryPointer.new(:double, num_class * input.count)
139
- check_result FFI.LGBM_BoosterPredictForMat(handle_pointer, data, 1, input.count, input.first.count, 1, 0, num_iteration, params_str(params), out_len, out_result)
142
+ 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)
140
143
  out = out_result.read_array_of_double(read_int64(out_len))
141
144
  out = out.each_slice(num_class).to_a if num_class > 1
142
145
 
@@ -145,7 +148,8 @@ module LightGBM
145
148
 
146
149
  def save_model(filename, num_iteration: nil, start_iteration: 0)
147
150
  num_iteration ||= best_iteration
148
- check_result FFI.LGBM_BoosterSaveModel(handle_pointer, start_iteration, num_iteration, filename)
151
+ feature_importance_type = 0 # TODO add
152
+ check_result FFI.LGBM_BoosterSaveModel(handle_pointer, start_iteration, num_iteration, feature_importance_type, filename)
149
153
  self # consistent with Python API
150
154
  end
151
155
 
@@ -175,10 +179,12 @@ module LightGBM
175
179
  def eval_names
176
180
  eval_counts ||= eval_counts()
177
181
  out_len = ::FFI::MemoryPointer.new(:int)
182
+ out_buffer_len = ::FFI::MemoryPointer.new(:size_t)
178
183
  out_strs = ::FFI::MemoryPointer.new(:pointer, eval_counts)
179
- str_ptrs = eval_counts.times.map { ::FFI::MemoryPointer.new(:char, 255) }
184
+ buffer_len = 255
185
+ str_ptrs = eval_counts.times.map { ::FFI::MemoryPointer.new(:char, buffer_len) }
180
186
  out_strs.write_array_of_pointer(str_ptrs)
181
- check_result FFI.LGBM_BoosterGetEvalNames(handle_pointer, out_len, out_strs)
187
+ check_result FFI.LGBM_BoosterGetEvalNames(handle_pointer, eval_counts, out_len, buffer_len, out_buffer_len, out_strs)
182
188
  str_ptrs.map(&:read_string)
183
189
  end
184
190
 
@@ -27,10 +27,13 @@ module LightGBM
27
27
  def feature_names
28
28
  # must preallocate space
29
29
  num_feature_names = ::FFI::MemoryPointer.new(:int)
30
- out_strs = ::FFI::MemoryPointer.new(:pointer, 1000)
31
- str_ptrs = 1000.times.map { ::FFI::MemoryPointer.new(:char, 255) }
30
+ out_buffer_len = ::FFI::MemoryPointer.new(:size_t)
31
+ len = 1000
32
+ out_strs = ::FFI::MemoryPointer.new(:pointer, len)
33
+ buffer_len = 255
34
+ str_ptrs = len.times.map { ::FFI::MemoryPointer.new(:char, buffer_len) }
32
35
  out_strs.write_array_of_pointer(str_ptrs)
33
- check_result FFI.LGBM_DatasetGetFeatureNames(handle_pointer, out_strs, num_feature_names)
36
+ check_result FFI.LGBM_DatasetGetFeatureNames(handle_pointer, len, num_feature_names, buffer_len, out_buffer_len, out_strs)
34
37
  str_ptrs[0, num_feature_names.read_int].map(&:read_string)
35
38
  end
36
39
 
@@ -23,7 +23,7 @@ module LightGBM
23
23
  attach_function :LGBM_DatasetCreateFromMat, %i[pointer int int32 int32 int string pointer pointer], :int
24
24
  attach_function :LGBM_DatasetGetSubset, %i[pointer pointer int32 string pointer], :int
25
25
  attach_function :LGBM_DatasetSetFeatureNames, %i[pointer pointer int], :int
26
- attach_function :LGBM_DatasetGetFeatureNames, %i[pointer pointer pointer], :int
26
+ attach_function :LGBM_DatasetGetFeatureNames, %i[pointer int pointer size_t pointer pointer], :int
27
27
  attach_function :LGBM_DatasetFree, %i[pointer], :int
28
28
  attach_function :LGBM_DatasetSaveBinary, %i[pointer string], :int
29
29
  attach_function :LGBM_DatasetDumpText, %i[pointer string], :int
@@ -44,13 +44,13 @@ module LightGBM
44
44
  attach_function :LGBM_BoosterNumModelPerIteration, %i[pointer pointer], :int
45
45
  attach_function :LGBM_BoosterNumberOfTotalModel, %i[pointer pointer], :int
46
46
  attach_function :LGBM_BoosterGetEvalCounts, %i[pointer pointer], :int
47
- attach_function :LGBM_BoosterGetEvalNames, %i[pointer pointer pointer], :int
47
+ attach_function :LGBM_BoosterGetEvalNames, %i[pointer int pointer size_t pointer pointer], :int
48
48
  attach_function :LGBM_BoosterGetNumFeature, %i[pointer pointer], :int
49
49
  attach_function :LGBM_BoosterGetEval, %i[pointer int pointer pointer], :int
50
- attach_function :LGBM_BoosterPredictForMat, %i[pointer pointer int int32 int32 int int int string pointer pointer], :int
51
- attach_function :LGBM_BoosterSaveModel, %i[pointer int int string], :int
52
- attach_function :LGBM_BoosterSaveModelToString, %i[pointer int int int64 pointer pointer], :int
53
- attach_function :LGBM_BoosterDumpModel, %i[pointer int int int64 pointer pointer], :int
50
+ attach_function :LGBM_BoosterPredictForMat, %i[pointer pointer int int32 int32 int int int int string pointer pointer], :int
51
+ attach_function :LGBM_BoosterSaveModel, %i[pointer int int int string], :int
52
+ attach_function :LGBM_BoosterSaveModelToString, %i[pointer int int int int64 pointer pointer], :int
53
+ attach_function :LGBM_BoosterDumpModel, %i[pointer int int int int64 pointer pointer], :int
54
54
  attach_function :LGBM_BoosterFeatureImportance, %i[pointer int int pointer], :int
55
55
  end
56
56
  end
@@ -1,3 +1,3 @@
1
1
  module LightGBM
2
- VERSION = "0.1.9"
2
+ VERSION = "0.2.0"
3
3
  end
Binary file
Binary file
Binary file
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.1.9
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-11 00:00:00.000000000 Z
11
+ date: 2020-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi