eps 0.3.9 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49da7dab8a04a1404446f56051ea9faaf5b2260888ef9e2eccf12ec0f5ece887
4
- data.tar.gz: 56a85a477e48cb07b39253e182878a947371ec30375b4570987c885a0e6bb93a
3
+ metadata.gz: ed82418a666490dc6683d0b1258c2dbc7451d86e9421bc5e1581a216e9b48a6f
4
+ data.tar.gz: d725f5e8f826f6e875aa06811a2d6cbf1fcbffd32073324eb43b32d6e99040eb
5
5
  SHA512:
6
- metadata.gz: 4a611604c4172110f67e3b39147ddb77346fe98390ee9a31791f61e1da2b4a6f1f6e83f63c4ab722c30d2247797c66328b9acefb51a907f76808793014207dd2
7
- data.tar.gz: 1aca1429a26a1eafee5717680507cf04794f639bb13c4ce416709bf0e64ca6017525413f74bcfa7728bd5272ff5b845dfb2da17cdee781eb03ea98a56c3441b3
6
+ metadata.gz: e3a8e472c998061e3a493ea2b2762a12747bac71d5544ca818bf69f50ac5e4c12cd7a2e0c5a8b767667c92238bbda54e7ef800f740210088fc982bfa84afa7a2
7
+ data.tar.gz: 2cdb0dda86b60c80a4a7fc4ad0fabafab71e57cfef8cdef349a190da4501e3105c1032b68f64c4196c99df1157da1a068d3bf6831b129b1544f925e371d924da
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.4.0 (2022-09-02)
2
+
3
+ - Fixed `stack level too deep` error with many rows
4
+ - Dropped support for `gsl` gem (use `gslr` instead)
5
+ - Dropped support for Ruby < 2.7
6
+
1
7
  ## 0.3.9 (2021-10-14)
2
8
 
3
9
  - Fixed error with `lessOrEqual` operator
data/README.md CHANGED
@@ -14,7 +14,7 @@ Check out [this post](https://ankane.org/rails-meet-data-science) for more info
14
14
  Add this line to your application’s Gemfile:
15
15
 
16
16
  ```ruby
17
- gem 'eps'
17
+ gem "eps"
18
18
  ```
19
19
 
20
20
  On Mac, also install OpenMP:
@@ -388,7 +388,7 @@ brew install gsl
388
388
  Then, add this line to your application’s Gemfile:
389
389
 
390
390
  ```ruby
391
- gem 'gslr', group: :development
391
+ gem "gslr", group: :development
392
392
  ```
393
393
 
394
394
  It only needs to be available in environments used to build the model.
@@ -85,6 +85,8 @@ module Eps
85
85
  finish -= 1 if rows.exclude_end?
86
86
  rows = Range.new(rows.begin, size - 1) if finish >= size - 1
87
87
  end
88
+ elsif rows.is_a?(Integer)
89
+ rows = [rows]
88
90
  end
89
91
 
90
92
  if cols
@@ -118,10 +120,11 @@ module Eps
118
120
  cols.each do |c|
119
121
  raise "Undefined column: #{c}" unless columns.include?(c)
120
122
 
121
- df.columns[c] = columns[c].values_at(*rows)
123
+ col = columns[c]
124
+ df.columns[c] = rows.map { |i| col[i] }
122
125
  end
123
- df.label = label.values_at(*rows) if label
124
- df.weight = weight.values_at(*rows) if weight
126
+ df.label = rows.map { |i| label[i] } if label
127
+ df.weight = rows.map { |i| weight[i] } if weight
125
128
 
126
129
  singular ? df.columns[cols[0]] : df
127
130
  end
@@ -37,8 +37,7 @@ module Eps
37
37
  str
38
38
  end
39
39
 
40
- # TODO use keyword arguments for gsl and intercept in 0.4.0
41
- def _train(**options)
40
+ def _train(intercept: true, gsl: nil)
42
41
  raise "Target must be numeric" if @target_type != "numeric"
43
42
  check_missing_value(@train_set)
44
43
  check_missing_value(@validation_set) if @validation_set
@@ -51,26 +50,16 @@ module Eps
51
50
 
52
51
  x = data.map_rows(&:to_a)
53
52
 
54
- gsl =
55
- if options.key?(:gsl)
56
- options[:gsl]
57
- elsif defined?(GSL)
58
- true
59
- elsif defined?(GSLR)
60
- :gslr
61
- else
62
- false
63
- end
53
+ gsl = defined?(GSLR) if gsl.nil?
64
54
 
65
- intercept = options.key?(:intercept) ? options[:intercept] : true
66
- if intercept && gsl != :gslr
55
+ if intercept && !gsl
67
56
  data.size.times do |i|
68
57
  x[i].unshift(1)
69
58
  end
70
59
  end
71
60
 
72
61
  v3 =
73
- if gsl == :gslr
62
+ if gsl
74
63
  model = GSLR::OLS.new(intercept: intercept)
75
64
  model.fit(x, data.label, weight: data.weight)
76
65
 
@@ -79,12 +68,6 @@ module Eps
79
68
  coefficients = model.coefficients.dup
80
69
  coefficients.unshift(model.intercept) if intercept
81
70
  coefficients
82
- elsif gsl
83
- x = GSL::Matrix.alloc(*x)
84
- y = GSL::Vector.alloc(data.label)
85
- w = GSL::Vector.alloc(data.weight) if data.weight
86
- c, @covariance, _, _ = w ? GSL::MultiFit.wlinear(x, w, y) : GSL::MultiFit.linear(x, y)
87
- c.to_a
88
71
  else
89
72
  x = Matrix.rows(x)
90
73
  y = Matrix.column_vector(data.label)
@@ -195,13 +178,7 @@ module Eps
195
178
  def p_value
196
179
  @p_value ||= begin
197
180
  Hash[@coefficients.map do |k, _|
198
- tp =
199
- if @gsl
200
- GSL::Cdf.tdist_P(t_value[k].abs, degrees_of_freedom)
201
- else
202
- Eps::Statistics.tdist_p(t_value[k].abs, degrees_of_freedom)
203
- end
204
-
181
+ tp = Eps::Statistics.tdist_p(t_value[k].abs, degrees_of_freedom)
205
182
  [k, 2 * (1 - tp)]
206
183
  end]
207
184
  end
data/lib/eps/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eps
2
- VERSION = "0.3.9"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.9
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: 2021-10-14 00:00:00.000000000 Z
11
+ date: 2022-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lightgbm
@@ -80,14 +80,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - ">="
82
82
  - !ruby/object:Gem::Version
83
- version: '2.4'
83
+ version: '2.7'
84
84
  required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - ">="
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
89
  requirements: []
90
- rubygems_version: 3.2.22
90
+ rubygems_version: 3.3.7
91
91
  signing_key:
92
92
  specification_version: 4
93
93
  summary: Machine learning for Ruby. Supports regression (linear regression) and classification