rbbt-dm 1.1.46 → 1.1.47
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rbbt/vector/model.rb +20 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eefb23100b9c066739e3d7fbeec940d6362d61b093770635f91e33c61d3a44a6
|
4
|
+
data.tar.gz: 4a7d70a7c252ef9a9e3edb4580eb9977186aa502d8e40c53d367a81244a26d2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3acf95a4b443a7bcf289a8f24dceec824a1d08453ff7cddbb470d608dedd324db5945893ea8c58668ad27d382e5fb1672fd327f207ac380f182be93ddf90b72c
|
7
|
+
data.tar.gz: 6b04078b2458a9c78481a1585ced18a6c5c7a81d1749422be29be510d735a8e8245d8a74fc446ed8895c801acb65ef5b33280e579abf6f8116cd1472d5efbef0
|
data/lib/rbbt/vector/model.rb
CHANGED
@@ -4,6 +4,20 @@ class VectorModel
|
|
4
4
|
attr_accessor :directory, :model_file, :extract_features, :train_model, :eval_model
|
5
5
|
attr_accessor :features, :labels
|
6
6
|
|
7
|
+
def self.R_run(model_file, features, labels, code)
|
8
|
+
TmpFile.with_file do |feature_file|
|
9
|
+
Open.write(feature_file, features.collect{|feats| feats * "\t"} * "\n")
|
10
|
+
Open.write(feature_file + '.class', labels * "\n")
|
11
|
+
|
12
|
+
R.run <<-EOF
|
13
|
+
features = read.table("#{ feature_file }", sep ="\\t", stringsAsFactors=FALSE);
|
14
|
+
labels = scan("#{ feature_file }.class");
|
15
|
+
features = cbind(features, class = labels);
|
16
|
+
#{code}
|
17
|
+
EOF
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
7
21
|
def self.R_train(model_file, features, labels, code)
|
8
22
|
TmpFile.with_file do |feature_file|
|
9
23
|
Open.write(feature_file, features.collect{|feats| feats * "\t"} * "\n")
|
@@ -72,16 +86,20 @@ cat(paste(label, sep="\\n"));
|
|
72
86
|
when Proc === train_model
|
73
87
|
train_model.call(@model_file, @features, @labels)
|
74
88
|
when String === train_model
|
75
|
-
|
89
|
+
VectorModel.R_train(@model_file, @features, @labels, train_model)
|
76
90
|
end
|
77
91
|
end
|
78
92
|
|
93
|
+
def run(code)
|
94
|
+
VectorModel.R_run(@model_file, @features, @labels, code)
|
95
|
+
end
|
96
|
+
|
79
97
|
def eval(element)
|
80
98
|
case
|
81
99
|
when Proc === eval_model
|
82
100
|
eval_model.call(@model_file, extract_features.call(element), false)
|
83
101
|
when String === eval_model
|
84
|
-
|
102
|
+
VectorModel.R_eval(@model_file, extract_features.call(element), false, eval_model)
|
85
103
|
end
|
86
104
|
end
|
87
105
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbbt-dm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.47
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbbt-util
|