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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rbbt/vector/model.rb +20 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f70d6a55c5852ffdafd59a3199b41031ee5a5aaa4becc56ee2f7f49be3b5d43
4
- data.tar.gz: f5d53ca95b6af4d6c2b63f00bbbfd398e3fa5a6feea15885b00ccd946f3aa765
3
+ metadata.gz: eefb23100b9c066739e3d7fbeec940d6362d61b093770635f91e33c61d3a44a6
4
+ data.tar.gz: 4a7d70a7c252ef9a9e3edb4580eb9977186aa502d8e40c53d367a81244a26d2b
5
5
  SHA512:
6
- metadata.gz: 7cd9928cd7a3e7558e27796f0e8f4c7635caa2331dc3f2d2d904434d9feedf6e3d2085ba301b55c61b87bdee83fbc588c666a99c0d0cc0d5414d1614a964a0a5
7
- data.tar.gz: f559bff1acc000be594ad8e91534a4af24acad3ebf80c276b8055af582a91e5137c748acf55267c8001b0c667cc1c6a167ca86a11b34da52ebb796ba8fdd01fe
6
+ metadata.gz: 3acf95a4b443a7bcf289a8f24dceec824a1d08453ff7cddbb470d608dedd324db5945893ea8c58668ad27d382e5fb1672fd327f207ac380f182be93ddf90b72c
7
+ data.tar.gz: 6b04078b2458a9c78481a1585ced18a6c5c7a81d1749422be29be510d735a8e8245d8a74fc446ed8895c801acb65ef5b33280e579abf6f8116cd1472d5efbef0
@@ -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
- SVMModel.R_train(@model_file, @features, @labels, train_model)
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
- SVMModel.R_eval(@model_file, extract_features.call(element), false, eval_model)
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.46
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-01-30 00:00:00.000000000 Z
11
+ date: 2020-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbbt-util