xgb 0.2.1 → 0.3.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: 79a40c703992619e8f834ff11e8eff704b96bf5eb0af8a47b4d0ab410cb68fff
4
- data.tar.gz: a8924ce9e90ee78d7ad4c98ae659f83e68155dfb5c1e3fcbed4797053c266922
3
+ metadata.gz: e9ad2900e477bc8e8fa5aca236a49fb4d41d8ec28b3c975049b16023a89cfe60
4
+ data.tar.gz: 3228781e80b95310a5c874b27fd69ab29ec875e79daf1bdbe99d09178c1ed2b2
5
5
  SHA512:
6
- metadata.gz: 2401d7accb4a2709c0ee0a9fd76b451bff641775fbe16f884de7b3a1288c7e210b1e3ea1b7b76734f8ff29aa9eac59ab161bb06b92340c7e7744ddf58fb8a8ae
7
- data.tar.gz: a256ab14fa84e7b10f54b7f465ccf0b261c1e7854ae85e1715e13e8d591a4fa756d5a2892e4783e2549cf6d9f29ab061438035ba305f7ab23e86341d53effb4a
6
+ metadata.gz: 228b317e43933701e2b9d3bdd0a1fc9c8781e64e2ec494b63a8be3efa5487350b022b64bcaffb4088e7e24c5698c39f23864248a87277e63d07ed7bd17573a09
7
+ data.tar.gz: f8cb92f5f10b20bb7342ee126a75cfb44fc85b0bd01e941b2031ad5b957be9c5c6060b22737ac04584f51eb0ed41668431c849a0417484358496606abf3690de
@@ -1,3 +1,7 @@
1
+ ## 0.3.0 (2020-02-19)
2
+
3
+ - Updated XGBoost to 1.0.0
4
+
1
5
  ## 0.2.1 (2020-02-11)
2
6
 
3
7
  - Fixed `Could not find XGBoost` error on some Linux platforms
data/README.md CHANGED
@@ -12,6 +12,12 @@ Add this line to your application’s Gemfile:
12
12
  gem 'xgb'
13
13
  ```
14
14
 
15
+ On Mac, also install OpenMP:
16
+
17
+ ```sh
18
+ brew install libomp
19
+ ```
20
+
15
21
  ## Learning API
16
22
 
17
23
  Prep your data
@@ -156,6 +156,14 @@ module XGBoost
156
156
  eval_hist
157
157
  end
158
158
 
159
+ def lib_version
160
+ major = ::FFI::MemoryPointer.new(:int)
161
+ minor = ::FFI::MemoryPointer.new(:int)
162
+ patch = ::FFI::MemoryPointer.new(:int)
163
+ FFI.XGBoostVersion(major, minor, patch)
164
+ "#{major.read_int}.#{minor.read_int}.#{patch.read_int}"
165
+ end
166
+
159
167
  private
160
168
 
161
169
  def mean(arr)
@@ -52,7 +52,7 @@ module XGBoost
52
52
  ntree_limit ||= 0
53
53
  out_len = ::FFI::MemoryPointer.new(:uint64)
54
54
  out_result = ::FFI::MemoryPointer.new(:pointer)
55
- check_result FFI.XGBoosterPredict(handle_pointer, data.handle_pointer, 0, ntree_limit, out_len, out_result)
55
+ check_result FFI.XGBoosterPredict(handle_pointer, data.handle_pointer, 0, ntree_limit, 0, out_len, out_result)
56
56
  out = out_result.read_pointer.read_array_of_float(read_uint64(out_len))
57
57
  num_class = out.size / data.num_row
58
58
  out = out.each_slice(num_class).to_a if num_class > 1
@@ -60,7 +60,7 @@ module XGBoost
60
60
  def group=(group)
61
61
  c_data = ::FFI::MemoryPointer.new(:int, group.size)
62
62
  c_data.write_array_of_int(group)
63
- check_result FFI.XGDMatrixSetGroup(handle_pointer, c_data, group.size)
63
+ check_result FFI.XGDMatrixSetUIntInfo(handle_pointer, "group", c_data, group.size)
64
64
  end
65
65
 
66
66
  def num_row
@@ -7,12 +7,13 @@ module XGBoost
7
7
  # https://github.com/dmlc/xgboost/blob/master/include/xgboost/c_api.h
8
8
  # keep same order
9
9
 
10
- # error
10
+ # general
11
+ attach_function :XGBoostVersion, %i[pointer pointer pointer], :void
11
12
  attach_function :XGBGetLastError, %i[], :string
12
13
 
13
14
  # dmatrix
14
15
  attach_function :XGDMatrixCreateFromMat, %i[pointer uint64 uint64 float pointer], :int
15
- attach_function :XGDMatrixSetGroup, %i[pointer pointer uint64], :int
16
+ attach_function :XGDMatrixSetUIntInfo, %i[pointer string pointer uint64], :int
16
17
  attach_function :XGDMatrixNumRow, %i[pointer pointer], :int
17
18
  attach_function :XGDMatrixNumCol, %i[pointer pointer], :int
18
19
  attach_function :XGDMatrixSliceDMatrix, %i[pointer pointer uint64 pointer], :int
@@ -27,7 +28,7 @@ module XGBoost
27
28
  attach_function :XGBoosterEvalOneIter, %i[pointer int pointer pointer uint64 pointer], :int
28
29
  attach_function :XGBoosterFree, %i[pointer], :int
29
30
  attach_function :XGBoosterSetParam, %i[pointer string string], :int
30
- attach_function :XGBoosterPredict, %i[pointer pointer int int pointer pointer], :int
31
+ attach_function :XGBoosterPredict, %i[pointer pointer int int int pointer pointer], :int
31
32
  attach_function :XGBoosterLoadModel, %i[pointer string], :int
32
33
  attach_function :XGBoosterSaveModel, %i[pointer string], :int
33
34
  attach_function :XGBoosterDumpModelEx, %i[pointer string int string pointer pointer], :int
@@ -2,12 +2,8 @@ module XGBoost
2
2
  class Model
3
3
  attr_reader :booster
4
4
 
5
- def initialize(max_depth: 3, learning_rate: 0.1, n_estimators: 100, objective: nil, importance_type: "gain", **options)
6
- @params = {
7
- max_depth: max_depth,
8
- objective: objective,
9
- learning_rate: learning_rate
10
- }.merge(options)
5
+ def initialize(n_estimators: 100, importance_type: "gain", **options)
6
+ @params = options
11
7
  @n_estimators = n_estimators
12
8
  @importance_type = importance_type
13
9
  end
@@ -1,6 +1,6 @@
1
1
  module XGBoost
2
2
  class Ranker < Model
3
- def initialize(max_depth: 3, learning_rate: 0.1, n_estimators: 100, objective: "rank:pairwise", importance_type: "gain", **options)
3
+ def initialize(n_estimators: 100, objective: "rank:pairwise", importance_type: "gain", **options)
4
4
  super
5
5
  end
6
6
 
@@ -1,3 +1,3 @@
1
1
  module XGBoost
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.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: xgb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.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-02-12 00:00:00.000000000 Z
11
+ date: 2020-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi