xgb 0.3.1 → 0.4.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: 295787749986ba153354f61845509079f470a5d11015c20cb89a5c58f04b133a
4
- data.tar.gz: e111099514e9a9a48d51a5033214a3e897eeff209302e47e1f30d79c818833c5
3
+ metadata.gz: 0d128d5d386edca28045cf55d4cd246f68deee2bb8e4a26254b9549955d2d8d4
4
+ data.tar.gz: 9e43a00b4b5f5f451ba7744effae622cfb404e67038de3881a6edfc5a776878a
5
5
  SHA512:
6
- metadata.gz: 803003072dafa5d2de97da7721042b94315b125f62f4f524f818923c5e5f8d3277624b146cedd7b88d9ca0769bec074e99717fb27ce56f5d2bf079ba627d52f7
7
- data.tar.gz: b9b14da27b6f8c03415d770c31dd16fdd112922daa2af3022df8554301eb5e43d0e873f21c65da13799e7a62d832cadbabff50188783aad5b5e7a577a9334005
6
+ metadata.gz: c7aaa6dd25ca9987621314b7ccee0b4fb029e0e6b70cce50a7fdaf9517c8896c6ad961b36b45af0ed2e6e2698bfd6d523a0fc623202cc058aa671821d9cec893
7
+ data.tar.gz: 603488b7920eed380a8eb5ca3576e3d5a1f4b7ba9cdc8afa75c0385558606b7e2865c8ddb9c21db43725b3cf379f75beb8cba35cf92d7d4717c85fedc7bf8ccb
@@ -1,3 +1,11 @@
1
+ ## 0.4.0 (2020-05-17)
2
+
3
+ - Updated XGBoost to 1.1.0
4
+ - Changed default `learning_rate` and `max_depth` for Scikit-Learn API to match Python
5
+ - Added support for Rover
6
+ - Improved performance of Numo datasets
7
+ - Improved error message when OpenMP not found on Mac
8
+
1
9
  ## 0.3.1 (2020-04-16)
2
10
 
3
11
  - Added `feature_names` and `feature_types` to `DMatrix`
data/README.md CHANGED
@@ -137,16 +137,22 @@ Data can be an array of arrays
137
137
  [[1, 2, 3], [4, 5, 6]]
138
138
  ```
139
139
 
140
- Or a Daru data frame
140
+ Or a Numo NArray
141
141
 
142
142
  ```ruby
143
- Daru::DataFrame.from_csv("houses.csv")
143
+ Numo::DFloat.new(3, 2).seq
144
144
  ```
145
145
 
146
- Or a Numo NArray
146
+ Or a Rover data frame
147
147
 
148
148
  ```ruby
149
- Numo::DFloat.new(3, 2).seq
149
+ Rover.read_csv("houses.csv")
150
+ ```
151
+
152
+ Or a Daru data frame
153
+
154
+ ```ruby
155
+ Daru::DataFrame.from_csv("houses.csv")
150
156
  ```
151
157
 
152
158
  ## Helpful Resources
@@ -1,6 +1,6 @@
1
1
  module XGBoost
2
2
  class Classifier < Model
3
- def initialize(max_depth: 3, learning_rate: 0.1, n_estimators: 100, objective: "binary:logistic", importance_type: "gain", **options)
3
+ def initialize(n_estimators: 100, objective: "binary:logistic", importance_type: "gain", **options)
4
4
  super
5
5
  end
6
6
 
@@ -27,18 +27,25 @@ module XGBoost
27
27
  raise Error, "Unknown feature type: #{v}"
28
28
  end
29
29
  end
30
- elsif narray?(data)
30
+ elsif numo?(data)
31
31
  nrow, ncol = data.shape
32
- flat_data = data.flatten.to_a
32
+ elsif rover?(data)
33
+ nrow, ncol = data.shape
34
+ @feature_names = data.keys
35
+ data = data.to_numo
33
36
  else
34
37
  nrow = data.count
35
38
  ncol = data.first.count
36
39
  flat_data = data.flatten
37
40
  end
38
41
 
39
- handle_missing(flat_data, missing)
40
42
  c_data = ::FFI::MemoryPointer.new(:float, nrow * ncol)
41
- c_data.write_array_of_float(flat_data)
43
+ if numo?(data)
44
+ c_data.write_bytes(data.cast_to(Numo::SFloat).to_string)
45
+ else
46
+ handle_missing(flat_data, missing)
47
+ c_data.write_array_of_float(flat_data)
48
+ end
42
49
  check_result FFI.XGDMatrixCreateFromMat(c_data, nrow, ncol, missing, @handle)
43
50
 
44
51
  ObjectSpace.define_finalizer(self, self.class.finalize(handle_pointer))
@@ -134,10 +141,14 @@ module XGBoost
134
141
  defined?(Daru::DataFrame) && data.is_a?(Daru::DataFrame)
135
142
  end
136
143
 
137
- def narray?(data)
144
+ def numo?(data)
138
145
  defined?(Numo::NArray) && data.is_a?(Numo::NArray)
139
146
  end
140
147
 
148
+ def rover?(data)
149
+ defined?(Rover::DataFrame) && data.is_a?(Rover::DataFrame)
150
+ end
151
+
141
152
  def handle_missing(data, missing)
142
153
  data.map! { |v| v.nil? ? missing : v }
143
154
  end
@@ -2,7 +2,15 @@ module XGBoost
2
2
  module FFI
3
3
  extend ::FFI::Library
4
4
 
5
- ffi_lib XGBoost.ffi_lib
5
+ begin
6
+ ffi_lib XGBoost.ffi_lib
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")
9
+ raise LoadError, "OpenMP not found. Run `brew install libomp`"
10
+ else
11
+ raise e
12
+ end
13
+ end
6
14
 
7
15
  # https://github.com/dmlc/xgboost/blob/master/include/xgboost/c_api.h
8
16
  # keep same order
@@ -1,6 +1,6 @@
1
1
  module XGBoost
2
2
  class Regressor < Model
3
- def initialize(max_depth: 3, learning_rate: 0.1, n_estimators: 100, objective: "reg:squarederror", importance_type: "gain", **options)
3
+ def initialize(n_estimators: 100, objective: "reg:squarederror", importance_type: "gain", **options)
4
4
  super
5
5
  end
6
6
 
@@ -1,3 +1,3 @@
1
1
  module XGBoost
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.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.3.1
4
+ version: 0.4.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-04-16 00:00:00.000000000 Z
11
+ date: 2020-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rover-df
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  description:
98
112
  email: andrew@chartkick.com
99
113
  executables: []