lightgbm 0.2.0 → 0.2.5

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: 2b3405aa832aaa365ce38d59bf5a36b318f8d02c1a236ea144eb9b102bf7f07e
4
- data.tar.gz: 5be378b94486a668fffdc276a73ff62f24a24b644932bd776fd877f4b69b157a
3
+ metadata.gz: ec446571f84421dcaf4d9453dce40aabdd8e76534e263b8de52566efc1d94560
4
+ data.tar.gz: 4be2791d0753e1f8848581c84c80c8952aa131e3eb33435293b37beee963ae19
5
5
  SHA512:
6
- metadata.gz: 914379fe9271306117fc222534915f3c19de1c6b165ecc053f49b9089da0b85594c8430958f03f28a23d98fcf2879c4948c8d3e5fecee920c2984700928380ec
7
- data.tar.gz: 4f93ae6b4a2c3123d452ecf41d7ada8473af397f12ddafb4e34b4e552aae4b6ef23ecb75b54ce3f7f64ba0985402c6172070de4afaca2ea614875f6d91c2de1a
6
+ metadata.gz: 03317e8af302bfbe6d3cd6b5d9499696c249bcfadaa0d265ca04cbd4b0d5801a1379cefc6789b1d0ad7e4d3ef1e2f9f3728f3654195823b55821b226141e41e8
7
+ data.tar.gz: b94edee304531f64a605785a707fdc4ae3b1d7879a121d98708ce5f32eef747d483f396e6a164f3fad76e0d0dcb63b46a05f68fa7fb57f3d7c6c2e1070ecabbe
data/CHANGELOG.md CHANGED
@@ -1,6 +1,27 @@
1
+ ## 0.2.5 (2021-07-07)
2
+
3
+ - Added `feature_name` method to boosters
4
+
5
+ ## 0.2.4 (2021-03-26)
6
+
7
+ - Updated LightGBM to 3.2.0
8
+
9
+ ## 0.2.3 (2021-03-09)
10
+
11
+ - Added ARM shared library for Mac
12
+
13
+ ## 0.2.2 (2020-12-07)
14
+
15
+ - Updated LightGBM to 3.1.1
16
+
17
+ ## 0.2.1 (2020-11-15)
18
+
19
+ - Updated LightGBM to 3.1.0
20
+
1
21
  ## 0.2.0 (2020-08-31)
2
22
 
3
23
  - Updated LightGBM to 3.0.0
24
+ - Made `best_iteration` and `eval_hist` consistent with Python
4
25
 
5
26
  ## 0.1.9 (2020-06-10)
6
27
 
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [LightGBM](https://github.com/microsoft/LightGBM) - high performance gradient boosting - for Ruby
4
4
 
5
- [![Build Status](https://travis-ci.org/ankane/lightgbm.svg?branch=master)](https://travis-ci.org/ankane/lightgbm)
5
+ [![Build Status](https://github.com/ankane/lightgbm/workflows/build/badge.svg?branch=master)](https://github.com/ankane/lightgbm/actions)
6
6
 
7
7
  ## Installation
8
8
 
data/lib/lightgbm.rb CHANGED
@@ -19,7 +19,12 @@ module LightGBM
19
19
  class << self
20
20
  attr_accessor :ffi_lib
21
21
  end
22
- lib_name = "lib_lightgbm.#{::FFI::Platform::LIBSUFFIX}"
22
+ lib_name =
23
+ if RbConfig::CONFIG["host_os"] =~ /darwin/i && RbConfig::CONFIG["host_cpu"] =~ /arm/i
24
+ "lib_lightgbm.arm64.#{::FFI::Platform::LIBSUFFIX}"
25
+ else
26
+ "lib_lightgbm.#{::FFI::Platform::LIBSUFFIX}"
27
+ end
23
28
  vendor_lib = File.expand_path("../vendor/#{lib_name}", __dir__)
24
29
  self.ffi_lib = [lib_name, "lib_lightgbm.so", vendor_lib]
25
30
 
@@ -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
 
@@ -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
@@ -5,7 +5,7 @@ module LightGBM
5
5
  begin
6
6
  ffi_lib LightGBM.ffi_lib
7
7
  rescue LoadError => e
8
- if e.message.include?("Library not loaded: /usr/local/opt/libomp/lib/libomp.dylib") && e.message.include?("Reason: image not found")
8
+ if ["/usr/local", "/opt/homebrew"].any? { |v| e.message.include?("Library not loaded: #{v}/opt/libomp/lib/libomp.dylib") } && e.message.include?("Reason: image not found")
9
9
  raise LoadError, "OpenMP not found. Run `brew install libomp`"
10
10
  else
11
11
  raise e
@@ -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
@@ -1,3 +1,3 @@
1
1
  module LightGBM
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.5"
3
3
  end
Binary file
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.2.0
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-01 00:00:00.000000000 Z
11
+ date: 2021-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -24,63 +24,7 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: minitest
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '5'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '5'
69
- - !ruby/object:Gem::Dependency
70
- name: daru
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- description:
27
+ description:
84
28
  email: andrew@chartkick.com
85
29
  executables: []
86
30
  extensions: []
@@ -100,6 +44,7 @@ files:
100
44
  - lib/lightgbm/utils.rb
101
45
  - lib/lightgbm/version.rb
102
46
  - vendor/LICENSE
47
+ - vendor/lib_lightgbm.arm64.dylib
103
48
  - vendor/lib_lightgbm.dll
104
49
  - vendor/lib_lightgbm.dylib
105
50
  - vendor/lib_lightgbm.so
@@ -107,7 +52,7 @@ homepage: https://github.com/ankane/lightgbm
107
52
  licenses:
108
53
  - MIT
109
54
  metadata: {}
110
- post_install_message:
55
+ post_install_message:
111
56
  rdoc_options: []
112
57
  require_paths:
113
58
  - lib
@@ -122,8 +67,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
67
  - !ruby/object:Gem::Version
123
68
  version: '0'
124
69
  requirements: []
125
- rubygems_version: 3.1.2
126
- signing_key:
70
+ rubygems_version: 3.2.3
71
+ signing_key:
127
72
  specification_version: 4
128
73
  summary: High performance gradient boosting for Ruby
129
74
  test_files: []