xgb 0.3.1 → 0.5.2

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: d2cea39eebbe29b40f1d4248bb9b4e3f4f112f2fcfcb2554bdf87c1fae0b5f3f
4
+ data.tar.gz: 197dcfb49e37fc72a3f5ab5bb593f0faa7912fbc60219c1b49dd235b869e57eb
5
5
  SHA512:
6
- metadata.gz: 803003072dafa5d2de97da7721042b94315b125f62f4f524f818923c5e5f8d3277624b146cedd7b88d9ca0769bec074e99717fb27ce56f5d2bf079ba627d52f7
7
- data.tar.gz: b9b14da27b6f8c03415d770c31dd16fdd112922daa2af3022df8554301eb5e43d0e873f21c65da13799e7a62d832cadbabff50188783aad5b5e7a577a9334005
6
+ metadata.gz: 6c58598a08cf976a2bf7b013ae3218f96ea6c96c0e345d2fe4d3e488ad8f409f905cf060e925b3307077cf844ae27babd9581bc3ff03c8c693cf812d08593808
7
+ data.tar.gz: 424a5542cb90830a017f976f706d85989f64d497dc2fd4351f95fb944ab8a48b51ad62f2b3fb7d4f1215428fdf49f913eb7b7c6beb82f0edebe35076c8f18ab3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,27 @@
1
+ ## 0.5.2 (2021-03-09)
2
+
3
+ - Added ARM shared library for Mac
4
+
5
+ ## 0.5.1 (2021-02-08)
6
+
7
+ - Fixed error with validation sets without early stopping
8
+
9
+ ## 0.5.0 (2020-12-12)
10
+
11
+ - Updated XGBoost to 1.3.0
12
+
13
+ ## 0.4.1 (2020-08-26)
14
+
15
+ - Updated XGBoost to 1.2.0
16
+
17
+ ## 0.4.0 (2020-05-17)
18
+
19
+ - Updated XGBoost to 1.1.0
20
+ - Changed default `learning_rate` and `max_depth` for Scikit-Learn API to match Python
21
+ - Added support for Rover
22
+ - Improved performance of Numo datasets
23
+ - Improved error message when OpenMP not found on Mac
24
+
1
25
  ## 0.3.1 (2020-04-16)
2
26
 
3
27
  - Added `feature_names` and `feature_types` to `DMatrix`
data/NOTICE.txt CHANGED
@@ -1,4 +1,5 @@
1
- Copyright 2019-2020 Andrew Kane
1
+ Copyright XGBoost contributors
2
+ Copyright 2019-2021 Andrew Kane
2
3
 
3
4
  Licensed under the Apache License, Version 2.0 (the "License");
4
5
  you may not use this file except in compliance with the License.
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [XGBoost](https://github.com/dmlc/xgboost) - high performance gradient boosting - for Ruby
4
4
 
5
- [![Build Status](https://travis-ci.org/ankane/xgboost.svg?branch=master)](https://travis-ci.org/ankane/xgboost) [![Build status](https://ci.appveyor.com/api/projects/status/s8umwyuahvj68m6p/branch/master?svg=true)](https://ci.appveyor.com/project/ankane/xgboost/branch/master)
5
+ [![Build Status](https://github.com/ankane/xgboost/workflows/build/badge.svg?branch=master)](https://github.com/ankane/xgboost/actions)
6
6
 
7
7
  ## Installation
8
8
 
@@ -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 array
141
141
 
142
142
  ```ruby
143
- Daru::DataFrame.from_csv("houses.csv")
143
+ Numo::NArray.cast([[1, 2, 3], [4, 5, 6]])
144
+ ```
145
+
146
+ Or a Rover data frame
147
+
148
+ ```ruby
149
+ Rover.read_csv("houses.csv")
144
150
  ```
145
151
 
146
- Or a Numo NArray
152
+ Or a Daru data frame
147
153
 
148
154
  ```ruby
149
- Numo::DFloat.new(3, 2).seq
155
+ Daru::DataFrame.from_csv("houses.csv")
150
156
  ```
151
157
 
152
158
  ## Helpful Resources
data/lib/xgboost.rb CHANGED
@@ -19,7 +19,12 @@ module XGBoost
19
19
  class << self
20
20
  attr_accessor :ffi_lib
21
21
  end
22
- lib_name = FFI.map_library_name("xgboost")
22
+ lib_name =
23
+ if RbConfig::CONFIG["host_os"] =~ /darwin/i && RbConfig::CONFIG["host_cpu"] =~ /arm/i
24
+ FFI.map_library_name("xgboost.arm64")
25
+ else
26
+ FFI.map_library_name("xgboost")
27
+ end
23
28
  vendor_lib = File.expand_path("../vendor/#{lib_name}", __dir__)
24
29
  self.ffi_lib = [vendor_lib]
25
30
 
@@ -61,7 +66,7 @@ module XGBoost
61
66
  best_score = score
62
67
  best_iter = iteration
63
68
  best_message = message
64
- elsif iteration - best_iter >= early_stopping_rounds
69
+ elsif early_stopping_rounds && iteration - best_iter >= early_stopping_rounds
65
70
  booster.best_iteration = best_iter
66
71
  puts "Stopping. Best iteration:\n#{best_message}" if verbose_eval
67
72
  break
@@ -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
data/lib/xgboost/ffi.rb CHANGED
@@ -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 ["/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
+ 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.5.2"
3
3
  end
Binary file
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.3.1
4
+ version: 0.5.2
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-04-16 00:00:00.000000000 Z
11
+ date: 2021-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -24,78 +24,8 @@ 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
- - !ruby/object:Gem::Dependency
84
- name: numo-narray
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- description:
98
- email: andrew@chartkick.com
27
+ description:
28
+ email: andrew@ankane.org
99
29
  executables: []
100
30
  extensions: []
101
31
  extra_rdoc_files: []
@@ -116,6 +46,7 @@ files:
116
46
  - lib/xgboost/utils.rb
117
47
  - lib/xgboost/version.rb
118
48
  - vendor/LICENSE
49
+ - vendor/libxgboost.arm64.dylib
119
50
  - vendor/libxgboost.dylib
120
51
  - vendor/libxgboost.so
121
52
  - vendor/xgboost.dll
@@ -123,7 +54,7 @@ homepage: https://github.com/ankane/xgboost
123
54
  licenses:
124
55
  - Apache-2.0
125
56
  metadata: {}
126
- post_install_message:
57
+ post_install_message:
127
58
  rdoc_options: []
128
59
  require_paths:
129
60
  - lib
@@ -138,8 +69,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
69
  - !ruby/object:Gem::Version
139
70
  version: '0'
140
71
  requirements: []
141
- rubygems_version: 3.1.2
142
- signing_key:
72
+ rubygems_version: 3.2.3
73
+ signing_key:
143
74
  specification_version: 4
144
75
  summary: High performance gradient boosting for Ruby
145
76
  test_files: []