scoruby 0.2.11 → 0.2.12
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/scoruby/{models_factory.rb → model_factory.rb} +12 -3
- data/lib/scoruby/models/gbm.rb +9 -1
- data/lib/scoruby/version.rb +1 -1
- data/lib/scoruby.rb +2 -2
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93c138affde68fe560e717bfae175c9d09482a60
|
4
|
+
data.tar.gz: bc5bc484924d557dd0eda09b85100203c2fb3ffd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cebad971eb0b272d45d8ca789e3cf93319066d7f0510ab6bc4798e09ee3d045513e1c2121106204adce8d7060e2d268f60cff748f88a3d248634a1577753089
|
7
|
+
data.tar.gz: 74a38b0428e889e3896a5c0942f11e20415861590354fede7cd0ffc2b76245af2627babfdfeea406bb5c2f8f92edc2e9c708607b88f9d4184059ad73e1152959
|
data/Gemfile.lock
CHANGED
@@ -6,9 +6,10 @@ require 'scoruby/models/random_forest/model'
|
|
6
6
|
require 'scoruby/models/naive_bayes/model'
|
7
7
|
|
8
8
|
module Scoruby
|
9
|
-
class
|
9
|
+
class ModelFactory
|
10
10
|
RANDOM_FOREST_MODEL = 'randomForest_Model'
|
11
|
-
|
11
|
+
GBM_INDICATION_4_2 = '//OutputField[@name="scaledGbmValue"]'
|
12
|
+
GBM_INDICATION_4_3 = '//OutputField[@name="gbmValue"]'
|
12
13
|
MODEL_NOT_SUPPORTED_ERROR = 'model not supported'
|
13
14
|
|
14
15
|
def self.factory_for(xml)
|
@@ -33,7 +34,15 @@ module Scoruby
|
|
33
34
|
end
|
34
35
|
|
35
36
|
def self.gbm?(xml)
|
36
|
-
|
37
|
+
gbm_4_2?(xml) || gbm_4_3?(xml)
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.gbm_4_2?(xml)
|
41
|
+
!xml.xpath(GBM_INDICATION_4_2).empty?
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.gbm_4_3?(xml)
|
45
|
+
!xml.xpath(GBM_INDICATION_4_3).empty?
|
37
46
|
end
|
38
47
|
end
|
39
48
|
end
|
data/lib/scoruby/models/gbm.rb
CHANGED
@@ -8,12 +8,13 @@ module Scoruby
|
|
8
8
|
class Gbm
|
9
9
|
GBM_FOREST_XPATH = '//Segmentation[@multipleModelMethod="sum"]/Segment'
|
10
10
|
CONST_XPATH = '//Target/@rescaleConstant'
|
11
|
+
CONST_XPATH_4_2 = '//Constant'
|
11
12
|
|
12
13
|
def initialize(xml)
|
13
14
|
@decision_trees = xml.xpath(GBM_FOREST_XPATH).map do |xml_tree|
|
14
15
|
DecisionTree.new(xml_tree)
|
15
16
|
end
|
16
|
-
@const =
|
17
|
+
@const = const(xml)
|
17
18
|
end
|
18
19
|
|
19
20
|
def tree_count
|
@@ -28,6 +29,13 @@ module Scoruby
|
|
28
29
|
sum = scores.reduce(:+) + @const
|
29
30
|
Math.exp(sum) / (1 + Math.exp(sum))
|
30
31
|
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def const(xml)
|
36
|
+
return Float(xml.xpath(CONST_XPATH).to_s) if ModelFactory.gbm_4_3?(xml)
|
37
|
+
Float(xml.xpath(CONST_XPATH_4_2).first.content)
|
38
|
+
end
|
31
39
|
end
|
32
40
|
end
|
33
41
|
end
|
data/lib/scoruby/version.rb
CHANGED
data/lib/scoruby.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'scoruby/version'
|
4
|
-
require 'scoruby/
|
4
|
+
require 'scoruby/model_factory'
|
5
5
|
require 'nokogiri'
|
6
6
|
require 'logger'
|
7
7
|
|
@@ -18,7 +18,7 @@ module Scoruby
|
|
18
18
|
|
19
19
|
def self.load_model(pmml_file_name)
|
20
20
|
xml = xml_from_file_path(pmml_file_name)
|
21
|
-
|
21
|
+
ModelFactory.factory_for(xml)
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.xml_from_file_path(pmml_file_name)
|
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.
|
4
|
+
version: 0.2.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Asaf Schers
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -130,13 +130,13 @@ files:
|
|
130
130
|
- lib/scoruby.rb
|
131
131
|
- lib/scoruby/decision.rb
|
132
132
|
- lib/scoruby/features.rb
|
133
|
+
- lib/scoruby/model_factory.rb
|
133
134
|
- lib/scoruby/models/decision_tree.rb
|
134
135
|
- lib/scoruby/models/gbm.rb
|
135
136
|
- lib/scoruby/models/naive_bayes/model.rb
|
136
137
|
- lib/scoruby/models/naive_bayes/model_data.rb
|
137
138
|
- lib/scoruby/models/random_forest/data.rb
|
138
139
|
- lib/scoruby/models/random_forest/model.rb
|
139
|
-
- lib/scoruby/models_factory.rb
|
140
140
|
- lib/scoruby/node.rb
|
141
141
|
- lib/scoruby/predicate_factory.rb
|
142
142
|
- lib/scoruby/predicates/compound_predicate.rb
|
@@ -169,9 +169,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
169
|
version: '0'
|
170
170
|
requirements: []
|
171
171
|
rubyforge_project:
|
172
|
-
rubygems_version: 2.
|
172
|
+
rubygems_version: 2.6.13
|
173
173
|
signing_key:
|
174
174
|
specification_version: 4
|
175
175
|
summary: Ruby Scoring API for PMML.
|
176
176
|
test_files: []
|
177
|
-
has_rdoc:
|