liblinear-ruby 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/liblinear/model.rb +24 -11
- data/lib/liblinear/version.rb +1 -1
- data/spec/liblinear/model_spec.rb +6 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e70466e2b89a0daa504f9dd8a655d759beb40260
|
4
|
+
data.tar.gz: e414010bb3853f7d2609e9e5a2fe34474d86e784
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 208a81ca1d8ebe5aaf221797417fbb3501a88f3a3d40310c65691980e3808463f5dc67c04cdea3ecf676b46b824d6506d9bfe0fb0f0d123094f39ae391454ec3
|
7
|
+
data.tar.gz: 848111ae60b0ae8422550f719fdf60d2ad701ee07a723da1c9e4c58e50dbce73f977a52eb1dc5ef8b981102d65d606e6333a15fa84fe1e5759f8852a35066ff9
|
data/lib/liblinear/model.rb
CHANGED
@@ -48,22 +48,35 @@ module Liblinear
|
|
48
48
|
# @param example [Array, Hash]
|
49
49
|
# @return [Hash]
|
50
50
|
def predict_probability(example)
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
labels.size.times do |i|
|
59
|
-
probability_list[labels[i]] = probabilities[i]
|
60
|
-
end
|
61
|
-
probability_list
|
51
|
+
predict_prob_val(example, :predict_probability)
|
52
|
+
end
|
53
|
+
|
54
|
+
# @param example [Array, Hash]
|
55
|
+
# @return [Hash]
|
56
|
+
def predict_values(example)
|
57
|
+
predict_prob_val(example, :predict_values)
|
62
58
|
end
|
63
59
|
|
64
60
|
# @param filename [String]
|
65
61
|
def save(filename)
|
66
62
|
save_model(filename, @model)
|
67
63
|
end
|
64
|
+
|
65
|
+
private
|
66
|
+
# @param example [Array, Hash]
|
67
|
+
# @return [Hash]
|
68
|
+
def predict_prob_val(example, liblinear_func)
|
69
|
+
feature_nodes = convert_to_feature_node_array(example, @model.nr_feature, @model.bias)
|
70
|
+
c_double_array = Liblinearswig.new_double(nr_class)
|
71
|
+
Liblinearswig.send(liblinear_func, @model, feature_nodes, c_double_array)
|
72
|
+
values = double_array_c_to_ruby(c_double_array, nr_class)
|
73
|
+
delete_double(c_double_array)
|
74
|
+
feature_node_array_destroy(feature_nodes)
|
75
|
+
value_list = {}
|
76
|
+
labels.size.times do |i|
|
77
|
+
value_list[labels[i]] = values[i]
|
78
|
+
end
|
79
|
+
value_list
|
80
|
+
end
|
68
81
|
end
|
69
82
|
end
|
data/lib/liblinear/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: liblinear-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kei Tsuchiya
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
version: '0'
|
135
135
|
requirements: []
|
136
136
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.0.
|
137
|
+
rubygems_version: 2.0.14
|
138
138
|
signing_key:
|
139
139
|
specification_version: 4
|
140
140
|
summary: Ruby wrapper of LIBLINEAR using SWIG
|
@@ -143,4 +143,3 @@ test_files:
|
|
143
143
|
- spec/liblinear/parameter_spec.rb
|
144
144
|
- spec/liblinear/problem_spec.rb
|
145
145
|
- spec/liblinear_spec.rb
|
146
|
-
has_rdoc:
|