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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +6 -0
- data/lib/xgboost.rb +8 -0
- data/lib/xgboost/booster.rb +1 -1
- data/lib/xgboost/dmatrix.rb +1 -1
- data/lib/xgboost/ffi.rb +4 -3
- data/lib/xgboost/model.rb +2 -6
- data/lib/xgboost/ranker.rb +1 -1
- data/lib/xgboost/version.rb +1 -1
- data/vendor/libxgboost.dylib +0 -0
- data/vendor/libxgboost.so +0 -0
- data/vendor/xgboost.dll +0 -0
- 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: e9ad2900e477bc8e8fa5aca236a49fb4d41d8ec28b3c975049b16023a89cfe60
|
4
|
+
data.tar.gz: 3228781e80b95310a5c874b27fd69ab29ec875e79daf1bdbe99d09178c1ed2b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 228b317e43933701e2b9d3bdd0a1fc9c8781e64e2ec494b63a8be3efa5487350b022b64bcaffb4088e7e24c5698c39f23864248a87277e63d07ed7bd17573a09
|
7
|
+
data.tar.gz: f8cb92f5f10b20bb7342ee126a75cfb44fc85b0bd01e941b2031ad5b957be9c5c6060b22737ac04584f51eb0ed41668431c849a0417484358496606abf3690de
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
data/lib/xgboost.rb
CHANGED
@@ -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)
|
data/lib/xgboost/booster.rb
CHANGED
@@ -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
|
data/lib/xgboost/dmatrix.rb
CHANGED
@@ -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.
|
63
|
+
check_result FFI.XGDMatrixSetUIntInfo(handle_pointer, "group", c_data, group.size)
|
64
64
|
end
|
65
65
|
|
66
66
|
def num_row
|
data/lib/xgboost/ffi.rb
CHANGED
@@ -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
|
-
#
|
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 :
|
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
|
data/lib/xgboost/model.rb
CHANGED
@@ -2,12 +2,8 @@ module XGBoost
|
|
2
2
|
class Model
|
3
3
|
attr_reader :booster
|
4
4
|
|
5
|
-
def initialize(
|
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
|
data/lib/xgboost/ranker.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module XGBoost
|
2
2
|
class Ranker < Model
|
3
|
-
def initialize(
|
3
|
+
def initialize(n_estimators: 100, objective: "rank:pairwise", importance_type: "gain", **options)
|
4
4
|
super
|
5
5
|
end
|
6
6
|
|
data/lib/xgboost/version.rb
CHANGED
data/vendor/libxgboost.dylib
CHANGED
Binary file
|
data/vendor/libxgboost.so
CHANGED
Binary file
|
data/vendor/xgboost.dll
CHANGED
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.
|
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-
|
11
|
+
date: 2020-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|