scoruby 0.3.2 → 0.3.3
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.rb +5 -0
- data/lib/scoruby/decision.rb +5 -1
- data/lib/scoruby/model_factory.rb +1 -1
- data/lib/scoruby/models/decision_tree.rb +1 -1
- data/lib/scoruby/models/gradient_boosted_model/data.rb +16 -6
- data/lib/scoruby/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18cd7707e6697afbec6c3f379673284e314a852e
|
4
|
+
data.tar.gz: ad6be58c00b30f7763e8605a8997037d034538d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f2a3a2bddcb481c1252d0715a2b7b20b56739797c38360d2f62911a9ca932fae6339748ea45255d4dd8b9e4a46d025580cfa9814a5c7167dd281a2fa628069c
|
7
|
+
data.tar.gz: e0fdc1cba17e1a026d6949395f6ba46040736dbccbcf31a05a558d483c377f7dc3b5d0d3dd1fabaf4c09053c997b803b3d5b9d273024ccd74e32997231ff5889
|
data/Gemfile.lock
CHANGED
data/lib/scoruby.rb
CHANGED
@@ -21,6 +21,11 @@ module Scoruby
|
|
21
21
|
ModelFactory.factory_for(xml)
|
22
22
|
end
|
23
23
|
|
24
|
+
def self.load_model_from_string(pmml_string)
|
25
|
+
xml = xml_from_string(pmml_string)
|
26
|
+
ModelFactory.factory_for(xml)
|
27
|
+
end
|
28
|
+
|
24
29
|
def self.xml_from_file_path(pmml_file_name)
|
25
30
|
pmml_string = File.open(pmml_file_name, 'rb').read
|
26
31
|
xml_from_string(pmml_string)
|
data/lib/scoruby/decision.rb
CHANGED
@@ -21,7 +21,11 @@ module Scoruby
|
|
21
21
|
def probability(score_distribution, xml)
|
22
22
|
probability = score_distribution.attributes['probability'].to_s
|
23
23
|
return probability.to_f if probability != ''
|
24
|
-
score_distribution
|
24
|
+
record_count(score_distribution) / record_count(xml)
|
25
|
+
end
|
26
|
+
|
27
|
+
def record_count(xml)
|
28
|
+
xml.attributes['recordCount'].to_s.to_f
|
25
29
|
end
|
26
30
|
end
|
27
31
|
end
|
@@ -31,7 +31,7 @@ module Scoruby
|
|
31
31
|
|
32
32
|
def self.random_forest?(xml)
|
33
33
|
xml.xpath('PMML/MiningModel/@modelName').to_s == RANDOM_FOREST_MODEL ||
|
34
|
-
xml.
|
34
|
+
xml.at('//Segmentation[@multipleModelMethod="average"]')
|
35
35
|
end
|
36
36
|
|
37
37
|
def self.gbm?(xml)
|
@@ -39,15 +39,18 @@ module Scoruby
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def fetch_categorical_features
|
42
|
-
|
43
|
-
.select { |xml| xml.attr('optype') == 'categorical' }
|
44
|
-
.reject { |xml| xml.attr('name') == target }
|
45
|
-
.each_with_object(Hash.new([])) do |xml, res|
|
42
|
+
categorical_features_xml.each_with_object(Hash.new([])) do |xml, res|
|
46
43
|
res[xml.attr('name').to_sym] = xml.xpath('Value')
|
47
44
|
.map { |xml| xml.attr('value') }
|
48
45
|
end
|
49
46
|
end
|
50
47
|
|
48
|
+
def categorical_features_xml
|
49
|
+
@xml.xpath('//DataField')
|
50
|
+
.select { |xml| xml.attr('optype') == 'categorical' }
|
51
|
+
.reject { |xml| xml.attr('name') == target }
|
52
|
+
end
|
53
|
+
|
51
54
|
def target
|
52
55
|
@target ||= @xml.xpath('//MiningField')
|
53
56
|
.find { |xml| xml.attr('usageType') == 'target' }
|
@@ -55,8 +58,15 @@ module Scoruby
|
|
55
58
|
end
|
56
59
|
|
57
60
|
def const_by_version
|
58
|
-
|
59
|
-
|
61
|
+
ModelFactory.gbm_4_3?(@xml) ? const_pmml_4_3 : const_pmml_4_2
|
62
|
+
end
|
63
|
+
|
64
|
+
def const_pmml_4_2
|
65
|
+
@xml.xpath(CONST_XPATH_4_2).first.content.to_f
|
66
|
+
end
|
67
|
+
|
68
|
+
def const_pmml_4_3
|
69
|
+
@xml.xpath(CONST_XPATH).to_s.to_f
|
60
70
|
end
|
61
71
|
end
|
62
72
|
end
|
data/lib/scoruby/version.rb
CHANGED
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.3.
|
4
|
+
version: 0.3.3
|
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-
|
11
|
+
date: 2018-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|