eps 0.3.2 → 0.3.3

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: 50f5a4273111ebc5ba1265d07d4e925d770006fce330b01cfbe4fe97221548d9
4
- data.tar.gz: a785ca5533618243b933248ef2f418c5d0d048d8ff1051c9a2e7fae5f8c87ba3
3
+ metadata.gz: 8133bd3887423fb41421aa2a4270aa0c7fc75b741ea60a6c55fb97308f3ddea4
4
+ data.tar.gz: '018283d9934459202f8395b4c3f4ba201894296e3cfa185bb884cc5b73981f0a'
5
5
  SHA512:
6
- metadata.gz: 3adffd0fbb0d16163a06720adfd97a83c6bf4bf2554e30b3a6f3599828511834826477a8296f93720c3efd52d19ca412e8b7695b013a4e7361073e3c5bcf5ee5
7
- data.tar.gz: 69847d6d49742f61b3b4fac6e9298e5c954d4cc22e5302b716f258e6190f71df4eee1820e844c4159e1fdf99385a36c2cb697065e78d5f6557c6d1dbca70f9de
6
+ metadata.gz: 2e1439f4a9a268a0434dc926a68822731db9267c746d4c76fa43a8debdbc49c25a502ff2051254fbf3453edb33141d35c02fa067afcddf2761e92b96e9d85751
7
+ data.tar.gz: 0c87d327d5f8083349cc75ea6b6e725e15ad20ac2535dc37dbc6b7955e6eca4408db93140287e8a9bfa7cee9da11956eb018600851bb07072c9e4347978d89dc
@@ -1,3 +1,8 @@
1
+ ## 0.3.3 (2020-02-24)
2
+
3
+ - Fixed errors and incorrect predictions with boolean columns
4
+ - Fixed deprecation warnings in Ruby 2.7
5
+
1
6
  ## 0.3.2 (2019-12-08)
2
7
 
3
8
  - Added support for GSLR
data/README.md CHANGED
@@ -357,7 +357,7 @@ Eps supports:
357
357
 
358
358
  #### Performance
359
359
 
360
- To speed up training on large datasets with linear regression, [install GSL](https://www.gnu.org/software/gsl/). With Homebrew, you can use:
360
+ To speed up training on large datasets with linear regression, [install GSL](https://github.com/ankane/gslr#gsl-installation). With Homebrew, you can use:
361
361
 
362
362
  ```sh
363
363
  brew install gsl
@@ -4,6 +4,7 @@ module Eps
4
4
  @options = options.dup
5
5
  # TODO better pattern - don't pass most options to train
6
6
  options.delete(:intercept)
7
+ @trained = false
7
8
  train(data, y, **options) if data
8
9
  end
9
10
 
@@ -48,6 +49,8 @@ module Eps
48
49
  end
49
50
 
50
51
  def summary(extended: false)
52
+ raise "Summary not available for loaded models" unless @trained
53
+
51
54
  str = String.new("")
52
55
 
53
56
  if @validation_set
@@ -169,6 +172,8 @@ module Eps
169
172
  # reset pmml
170
173
  @pmml = nil
171
174
 
175
+ @trained = true
176
+
172
177
  nil
173
178
  end
174
179
 
@@ -205,7 +210,7 @@ module Eps
205
210
 
206
211
  # TODO determine max features automatically
207
212
  # start based on number of rows
208
- encoder = Eps::TextEncoder.new(v)
213
+ encoder = Eps::TextEncoder.new(**v)
209
214
  counts = encoder.fit(train_set.columns.delete(k))
210
215
  encoder.vocabulary.each do |word|
211
216
  train_set.columns[[k, word]] = [0] * counts.size
@@ -16,7 +16,7 @@ module Eps
16
16
 
17
17
  # sparse matrix
18
18
  @text_features.each do |k, v|
19
- encoder = TextEncoder.new(v)
19
+ encoder = TextEncoder.new(**v)
20
20
 
21
21
  values = data.columns.delete(k)
22
22
  counts = encoder.transform(values)
@@ -81,7 +81,7 @@ module Eps
81
81
  else
82
82
  case node.operator
83
83
  when "equal"
84
- v == node.value
84
+ v.to_s == node.value
85
85
  when "in"
86
86
  node.value.include?(v)
87
87
  when "greaterThan"
@@ -19,10 +19,11 @@ module Eps
19
19
  case type
20
20
  when "categorical"
21
21
  x.columns[k].each_with_index do |xv, i|
22
- scores[i] += @coefficients[[k, xv]].to_f
22
+ # TODO clean up
23
+ scores[i] += (@coefficients[[k, xv]] || @coefficients[[k, xv.to_s]]).to_f
23
24
  end
24
25
  when "text"
25
- encoder = TextEncoder.new(@text_features[k])
26
+ encoder = TextEncoder.new(**@text_features[k])
26
27
  counts = encoder.transform(x.columns[k])
27
28
  coef = {}
28
29
  @coefficients.each do |k2, v|
@@ -38,7 +38,8 @@ module Eps
38
38
  case type
39
39
  when "categorical"
40
40
  x.columns[k].each_with_index do |xi, i|
41
- vc = probabilities[:conditional][k][xi]
41
+ # TODO clean this up
42
+ vc = probabilities[:conditional][k][xi] || probabilities[:conditional][k][xi.to_s]
42
43
 
43
44
  # unknown value if not vc
44
45
  if vc
@@ -210,10 +210,10 @@ module Eps
210
210
  probabilities[:conditional].each do |k, v|
211
211
  xml.BayesInput(fieldName: k) do
212
212
  if features[k] == "categorical"
213
- v.sort_by { |k2, _| k2 }.each do |k2, v2|
213
+ v.sort_by { |k2, _| k2.to_s }.each do |k2, v2|
214
214
  xml.PairCounts(value: k2) do
215
215
  xml.TargetValueCounts do
216
- v2.sort_by { |k2, _| k2 }.each do |k3, v3|
216
+ v2.sort_by { |k2, _| k2.to_s }.each do |k3, v3|
217
217
  xml.TargetValueCount(value: k3, count: v3)
218
218
  end
219
219
  end
@@ -221,7 +221,7 @@ module Eps
221
221
  end
222
222
  else
223
223
  xml.TargetValueStats do
224
- v.sort_by { |k2, _| k2 }.each do |k2, v2|
224
+ v.sort_by { |k2, _| k2.to_s }.each do |k2, v2|
225
225
  xml.TargetValueStat(value: k2) do
226
226
  xml.GaussianDistribution(mean: v2[:mean], variance: v2[:stdev]**2)
227
227
  end
@@ -233,7 +233,7 @@ module Eps
233
233
  end
234
234
  xml.BayesOutput(fieldName: "target") do
235
235
  xml.TargetValueCounts do
236
- probabilities[:prior].sort_by { |k, _| k }.each do |k, v|
236
+ probabilities[:prior].sort_by { |k, _| k.to_s }.each do |k, v|
237
237
  xml.TargetValueCount(value: k, count: v)
238
238
  end
239
239
  end
@@ -1,3 +1,3 @@
1
1
  module Eps
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
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.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-09 00:00:00.000000000 Z
11
+ date: 2020-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lightgbm
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  - !ruby/object:Gem::Version
144
144
  version: '0'
145
145
  requirements: []
146
- rubygems_version: 3.0.3
146
+ rubygems_version: 3.1.2
147
147
  signing_key:
148
148
  specification_version: 4
149
149
  summary: Machine learning for Ruby. Supports regression (linear regression) and classification