scoruby 0.2.10 → 0.2.11

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
- SHA256:
3
- metadata.gz: 0ee4282e8fcb20ef06123e1088adee0ab4ca6688174b67a46b26bf75d7fa1145
4
- data.tar.gz: 4bcfeefdc4bc807f689906b00f25cced00a8f22b1c35ec33fb2764dd99e32e77
2
+ SHA1:
3
+ metadata.gz: 00aa54edc46f55d9595e7f972b2983be9389c269
4
+ data.tar.gz: 3a191d0e24aa19310106d6eb99b67541e7edd4ed
5
5
  SHA512:
6
- metadata.gz: 2682ec9cc3ef358126acf13ae4da429a2fc2b2d31be16ce9adc1a8709f8998d74591f94adfdb7e2a3205c0318dfa6f5036d18e99d2e233df14c2f6bbbc176074
7
- data.tar.gz: 6dba495a98c17393dd56dbd747e568e02d1b70e7d24ad121f3bc18c71e8f68b972911530e73ae40917443f9e33cb3b5d4bd1ee507f856de6dbf8b2b86901c7a1
6
+ metadata.gz: 192cb38df033c13c9dbda5871dd9e88222638912fd1a86cdb1ad530174a1da2c92d94217cab2063579836acdbfb3c0fdd5e28768580484fe0b3d247a1063c11e
7
+ data.tar.gz: 1f7560f9d42563feea72eaa11e380a30df1e6d02443eda182e2fb4853650da879605ccbb8726936bb00919581244b7ce129c50a354f8098e4b8cc9bb5385eb57
data/.travis.yml CHANGED
@@ -3,4 +3,5 @@ rvm:
3
3
  - 2.2.8
4
4
  - 2.3.5
5
5
  - 2.4.2
6
- before_install: gem install bundler -v 1.15.4
6
+
7
+
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- scoruby (0.2.10)
4
+ scoruby (0.2.11)
5
5
  nokogiri (~> 1.7)
6
6
 
7
7
  GEM
@@ -4,16 +4,24 @@ module Scoruby
4
4
  class Decision
5
5
  attr_reader :score, :score_distribution
6
6
 
7
- def initialize(score, score_distributions)
8
- @score = score
9
- return if score_distributions.empty?
7
+ def initialize(xml)
8
+ children = xml.children
9
+ distributions = children.select { |c| c.name == 'ScoreDistribution' }
10
+
11
+ @score = xml.attribute('score').to_s
12
+ return if distributions.empty?
10
13
 
11
14
  @score_distribution = {}
12
- score_distributions.each do |score_distribution|
15
+ distributions.each do |score_distribution|
13
16
  value = score_distribution.attributes['value'].to_s
14
- probability = score_distribution.attributes['probability'].to_s
15
- @score_distribution[value] = probability
17
+ @score_distribution[value] = probability(score_distribution, xml)
16
18
  end
17
19
  end
20
+
21
+ def probability(score_distribution, xml)
22
+ probability = score_distribution.attributes['probability'].to_s
23
+ return probability.to_f if probability != ''
24
+ score_distribution.attributes['recordCount'].to_s.to_f / xml.attributes['recordCount'].to_s.to_f
25
+ end
18
26
  end
19
27
  end
data/lib/scoruby/node.rb CHANGED
@@ -9,9 +9,7 @@ module Scoruby
9
9
 
10
10
  def initialize(xml)
11
11
  children = xml.children
12
- distributions = children.select { |c| c.name == 'ScoreDistribution' }
13
- @decision = Decision.new(xml.attribute('score').to_s,
14
- distributions)
12
+ @decision = Decision.new(xml)
15
13
  children = remove_nodes(children)
16
14
  @pred = PredicateFactory.for(children[0])
17
15
  @children = children_nodes(children)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Scoruby
4
- VERSION = '0.2.10'
4
+ VERSION = '0.2.11'
5
5
  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.10
4
+ version: 0.2.11
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-12-30 00:00:00.000000000 Z
11
+ date: 2018-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -169,8 +169,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
169
  version: '0'
170
170
  requirements: []
171
171
  rubyforge_project:
172
- rubygems_version: 2.7.3
172
+ rubygems_version: 2.2.2
173
173
  signing_key:
174
174
  specification_version: 4
175
175
  summary: Ruby Scoring API for PMML.
176
176
  test_files: []
177
+ has_rdoc: