scoruby 0.2.3 → 0.2.4

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
  SHA1:
3
- metadata.gz: 59d91f99c8a04a124993b71950d425f6b1b89353
4
- data.tar.gz: ee709d362a7699749561a7d1cb60f7b7aa40c902
3
+ metadata.gz: 5ab6779638032408bc0a38812ded29891831aebd
4
+ data.tar.gz: d26d4338fdbb2f00a7d6fed974a6e2d577c1d847
5
5
  SHA512:
6
- metadata.gz: 4d433e761e5fc203d298ecec3fb5019e024ae6cd753296f08b304fc0dd790017f5ff0e8621a34995811d6db21c475f3e91a41d079722c5c1ec888d151740c9c6
7
- data.tar.gz: c347e88a7cf8e5345be89160f6f6f6f07ff2bb7dfed93401f02700e898886b3205e0ced850ba1fad247779f4b0f16c712b751aca46be15ac0d75b6fe3f1cc9d1
6
+ metadata.gz: 080081fe11bdba935bdd99b178ce74a04d1d05dadc080283f9e474a4d84e8415d2a39cf6a9916c4ee46c78fb46965aa934a0850491de04f6fd1d5806aaa32463
7
+ data.tar.gz: 38a7ac8547797f2367fcd66036ea87971c531106c0dd0b4c56abf684f48a72db14a9139fa5ff29b0e809aadb5ffb0908a265a603aa6d3ddf5725dc4858cdab0a
data/.gitignore CHANGED
@@ -1,10 +1,14 @@
1
1
  .idea
2
- *.log
3
-
4
- test_gbm.rb
2
+ coverage
5
3
 
6
- test_gbm.pmml
4
+ *.log
7
5
 
8
6
  *.gem
9
7
 
8
+ spec/fixtures/decision_tree_v2.pmml
9
+
10
10
  sample.pmml
11
+
12
+ test_gbm.pmml
13
+
14
+ test_gbm.rb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- scoruby (0.2.2)
4
+ scoruby (0.2.4)
5
5
  nokogiri (~> 1.7)
6
6
 
7
7
  GEM
@@ -1,4 +1,4 @@
1
- require 'node'
1
+ require 'scoruby/node'
2
2
 
3
3
  module Scoruby
4
4
  module Models
@@ -25,15 +25,9 @@ module Scoruby
25
25
  private
26
26
 
27
27
  def step(curr, features)
28
- curr = step_on_true(curr, features, 0)
29
- curr = step_on_true(curr, features, 1)
30
- curr = step_on_true(curr, features, 2)
31
- curr
32
- end
33
-
34
- def step_on_true(curr, features, num)
35
- return curr.children[num] if curr.children && curr.children[num] && curr.children[num].true?(features)
36
- curr
28
+ return curr unless curr.children
29
+ next_step = curr.children.find { |c| c && c.true?(features) }
30
+ next_step || curr
37
31
  end
38
32
 
39
33
  def didnt_step?(curr, prev)
@@ -1,5 +1,5 @@
1
- require 'models/decision_tree'
2
- require 'features'
1
+ require 'scoruby/models/decision_tree'
2
+ require 'scoruby/features'
3
3
 
4
4
  module Scoruby
5
5
  module Models
@@ -1,6 +1,6 @@
1
- require 'models/decision_tree'
2
- require 'models/gbm'
3
- require 'models/random_forest'
1
+ require 'scoruby/models/decision_tree'
2
+ require 'scoruby/models/gbm'
3
+ require 'scoruby/models/random_forest'
4
4
 
5
5
  module Scoruby
6
6
  class ModelsFactory
data/lib/scoruby/node.rb CHANGED
@@ -1,5 +1,5 @@
1
- require 'predicate_factory'
2
- require 'decision'
1
+ require 'scoruby/predicate_factory'
2
+ require 'scoruby/decision'
3
3
 
4
4
  module Scoruby
5
5
  class Node
@@ -13,16 +13,9 @@ module Scoruby
13
13
  children.select {|c| c.name == 'ScoreDistribution'})
14
14
 
15
15
  children = remove_nodes(children)
16
-
17
- pred_xml = children[0]
18
- @pred = PredicateFactory.for(pred_xml)
19
- @children = []
20
-
21
- return if children.count == 1
22
-
23
- @children << Node.new(children[1]) if children[1]
24
- @children << Node.new(children[2]) if children[2]
25
- @children << Node.new(children[3]) if children[3]
16
+
17
+ @pred = PredicateFactory.for(children[0])
18
+ @children = children_nodes(children)
26
19
  end
27
20
 
28
21
  def true?(features)
@@ -31,6 +24,11 @@ module Scoruby
31
24
 
32
25
  private
33
26
 
27
+ def children_nodes(children)
28
+ children.select { |c| c.name == 'Node' }
29
+ .map { |child| Node.new(child) }
30
+ end
31
+
34
32
  def remove_nodes(children)
35
33
  children.reject {|c| %w(Extension ScoreDistribution).include? c.name}
36
34
  end
@@ -1,8 +1,8 @@
1
- require 'predicates/compound_predicate'
2
- require 'predicates/simple_predicate'
3
- require 'predicates/simple_set_predicate'
4
- require 'predicates/true_predicate'
5
- require 'predicates/false_predicate'
1
+ require 'scoruby/predicates/compound_predicate'
2
+ require 'scoruby/predicates/simple_predicate'
3
+ require 'scoruby/predicates/simple_set_predicate'
4
+ require 'scoruby/predicates/true_predicate'
5
+ require 'scoruby/predicates/false_predicate'
6
6
 
7
7
  module Scoruby
8
8
  class PredicateFactory
@@ -1,3 +1,3 @@
1
1
  module Scoruby
2
- VERSION = '0.2.3'
2
+ VERSION = '0.2.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scoruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Asaf Schers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-20 00:00:00.000000000 Z
11
+ date: 2017-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler