scoruby 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Gemfile.lock +1 -1
- data/README.md +12 -13
- data/lib/scoruby/models/naive_bayes/model_data.rb +1 -1
- data/lib/scoruby/models/random_forest.rb +5 -1
- data/lib/scoruby/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aba708affa4e656a44a43d1f24b71b696760b7bd
|
4
|
+
data.tar.gz: d52253a2d308e3d7f7749f379feae9757e866887
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f1dcf1c79cea6278c5a584c7390acaf275104fde029e83514d3cbf39859c840944d3893076c658c6eca9506add2c192525f5fbf6f6c65e1e8871ff5ddd6429f
|
7
|
+
data.tar.gz: e9d4f29650d95e74ae6e45c5fd5a4ef8435d552b792f558c9e15c07ce6d4d02f2bbe64ae34d07cfcbc55a4afe0f554df2adb79b25d0a1dfc69d611cc3b660a8a
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
Ruby scoring API for Predictive Model Markup Language (PMML).
|
9
9
|
|
10
|
-
Currently supports Decision Tree, Random Forest and Gradient Boosted Models.
|
10
|
+
Currently supports Decision Tree, Random Forest Naive Bayes and Gradient Boosted Models.
|
11
11
|
|
12
12
|
Will be happy to implement new models by demand, or assist with any other issue.
|
13
13
|
|
@@ -50,7 +50,7 @@ features = {
|
|
50
50
|
|
51
51
|
random_forest.predict(features)
|
52
52
|
|
53
|
-
=> "0"
|
53
|
+
=> {:label=>"0", :score=>0.882}
|
54
54
|
|
55
55
|
random_forest.decisions_count(features)
|
56
56
|
|
@@ -88,22 +88,21 @@ gbm.score(features)
|
|
88
88
|
|
89
89
|
```ruby
|
90
90
|
decision_tree = Scoruby.get_model 'decision_tree.pmml'
|
91
|
-
|
92
|
-
features = {
|
93
|
-
Sex: 'male',
|
94
|
-
Parch: 0,
|
95
|
-
Age: 30,
|
96
|
-
Fare: 9.6875,
|
97
|
-
Pclass: 2,
|
98
|
-
SibSp: 0,
|
99
|
-
Embarked: 'Q'
|
100
|
-
}
|
101
|
-
|
91
|
+
features = { f1 : v1, ... }
|
102
92
|
decision_tree.decide(features)
|
103
93
|
|
104
94
|
=> #<Decision:0x007fc232384180 @score="0", @score_distribution={"0"=>"0.999615579933873", "1"=>"0.000384420066126561"}>
|
105
95
|
```
|
106
96
|
|
97
|
+
### Naibve Bayes
|
98
|
+
|
99
|
+
```ruby
|
100
|
+
naive_bayes = Scoruby.get_model 'naive_bayes.pmml'
|
101
|
+
features = { f1: v1 , ... }
|
102
|
+
naive_bayes.lvalues(features)
|
103
|
+
naive_bayes.score(features, 'l1')
|
104
|
+
```
|
105
|
+
|
107
106
|
## Development
|
108
107
|
|
109
108
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -19,7 +19,11 @@ module Scoruby
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def predict(features)
|
22
|
-
decisions_count(features)
|
22
|
+
decisions_count = decisions_count(features)
|
23
|
+
{
|
24
|
+
label: decisions_count.max_by {|_, v| v}[0],
|
25
|
+
score: decisions_count.max_by {|_, v| v}[1] / decisions_count.values.reduce(0, :+).to_f
|
26
|
+
}
|
23
27
|
end
|
24
28
|
end
|
25
29
|
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.2.
|
4
|
+
version: 0.2.7
|
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-
|
11
|
+
date: 2017-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -167,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
167
|
version: '0'
|
168
168
|
requirements: []
|
169
169
|
rubyforge_project:
|
170
|
-
rubygems_version: 2.
|
170
|
+
rubygems_version: 2.4.8
|
171
171
|
signing_key:
|
172
172
|
specification_version: 4
|
173
173
|
summary: Ruby Scoring API for PMML.
|