rbbt-dm 1.1.45 → 1.1.46
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/rbbt/ml_task.rb +7 -0
- data/lib/rbbt/vector/model/svm.rb +1 -1
- data/lib/rbbt/vector/model.rb +54 -0
- data/test/rbbt/test_ml_task.rb +12 -0
- data/test/rbbt/vector/test_model.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5f70d6a55c5852ffdafd59a3199b41031ee5a5aaa4becc56ee2f7f49be3b5d43
|
4
|
+
data.tar.gz: f5d53ca95b6af4d6c2b63f00bbbfd398e3fa5a6feea15885b00ccd946f3aa765
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cd9928cd7a3e7558e27796f0e8f4c7635caa2331dc3f2d2d904434d9feedf6e3d2085ba301b55c61b87bdee83fbc588c666a99c0d0cc0d5414d1614a964a0a5
|
7
|
+
data.tar.gz: f559bff1acc000be594ad8e91534a4af24acad3ebf80c276b8055af582a91e5137c748acf55267c8001b0c667cc1c6a167ca86a11b34da52ebb796ba8fdd01fe
|
data/lib/rbbt/ml_task.rb
ADDED
data/lib/rbbt/vector/model.rb
CHANGED
@@ -57,6 +57,11 @@ cat(paste(label, sep="\\n"));
|
|
57
57
|
@labels = []
|
58
58
|
end
|
59
59
|
|
60
|
+
def clear
|
61
|
+
@features = []
|
62
|
+
@labels = []
|
63
|
+
end
|
64
|
+
|
60
65
|
def add(element, label = nil)
|
61
66
|
@features << extract_features.call(element)
|
62
67
|
@labels << label unless label.nil?
|
@@ -119,4 +124,53 @@ cat(paste(label, sep="\\n"));
|
|
119
124
|
|
120
125
|
acc
|
121
126
|
end
|
127
|
+
|
128
|
+
def cross_validation(folds = 10)
|
129
|
+
|
130
|
+
res = TSV.setup({}, "Fold~TP,TN,FP,FN,P,R,F1#:type=:list")
|
131
|
+
|
132
|
+
feature_folds = Misc.divide(@features, folds)
|
133
|
+
labels_folds = Misc.divide(@labels, folds)
|
134
|
+
|
135
|
+
folds.times do |fix|
|
136
|
+
|
137
|
+
test_set = feature_folds[fix]
|
138
|
+
train_set = feature_folds.values_at(*((0..9).to_a - [fix])).inject([]){|acc,e| acc += e; acc}
|
139
|
+
|
140
|
+
test_labels = labels_folds[fix]
|
141
|
+
train_labels = labels_folds.values_at(*((0..9).to_a - [fix])).flatten
|
142
|
+
|
143
|
+
tp, fp, tn, fn, pr, re, f1 = [0, 0, 0, 0, nil, nil, nil]
|
144
|
+
|
145
|
+
@features = train_set
|
146
|
+
@labels = train_labels
|
147
|
+
self.train
|
148
|
+
predictions = self.eval_list test_set, false
|
149
|
+
|
150
|
+
test_labels.zip(predictions).each do |gs,pred|
|
151
|
+
gs = gs.to_i
|
152
|
+
pred = pred > 0.5 ? 1 : 0
|
153
|
+
tp += 1 if gs == pred && gs == 1
|
154
|
+
tn += 1 if gs == pred && gs == 0
|
155
|
+
fp += 1 if gs == 0 && pred == 1
|
156
|
+
fn += 1 if gs == 1 && pred == 0
|
157
|
+
end
|
158
|
+
|
159
|
+
p = tp + fn
|
160
|
+
pp = tp + fp
|
161
|
+
|
162
|
+
pr = tp.to_f / pp
|
163
|
+
re = tp.to_f / p
|
164
|
+
|
165
|
+
f1 = (2.0 * tp) / (2.0 * tp + fp + fn)
|
166
|
+
|
167
|
+
Misc.fingerprint([tp,tn,fp,fn,pr,re,f1])
|
168
|
+
|
169
|
+
Log.debug "CV Fold #{fix} P:#{"%.3f" % pr} R:#{"%.3f" % re} F1:#{"%.3f" % f1}"
|
170
|
+
|
171
|
+
res[fix] = [tp,tn,fp,fn,pr,re,f1]
|
172
|
+
end
|
173
|
+
|
174
|
+
res
|
175
|
+
end
|
122
176
|
end
|
@@ -34,7 +34,7 @@ class TestVectorModel < Test::Unit::TestCase
|
|
34
34
|
features = read.table("#{ feature_file }", sep ="\\t", stringsAsFactors=FALSE);
|
35
35
|
labels = scan("#{ feature_file }.class", what=numeric());
|
36
36
|
features = cbind(features, class = labels);
|
37
|
-
|
37
|
+
rbbt.require('e1071')
|
38
38
|
model = svm(class ~ ., data = features)
|
39
39
|
save(model, file="#{ model_file }");
|
40
40
|
EOF
|
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.46
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbbt-util
|
@@ -95,6 +95,7 @@ files:
|
|
95
95
|
- lib/rbbt/matrix/barcode.rb
|
96
96
|
- lib/rbbt/matrix/differential.rb
|
97
97
|
- lib/rbbt/matrix/knowledge_base.rb
|
98
|
+
- lib/rbbt/ml_task.rb
|
98
99
|
- lib/rbbt/network/paths.rb
|
99
100
|
- lib/rbbt/plots/bar.rb
|
100
101
|
- lib/rbbt/plots/heatmap.rb
|
@@ -115,6 +116,7 @@ files:
|
|
115
116
|
- test/rbbt/statistics/test_fisher.rb
|
116
117
|
- test/rbbt/statistics/test_hypergeometric.rb
|
117
118
|
- test/rbbt/statistics/test_random_walk.rb
|
119
|
+
- test/rbbt/test_ml_task.rb
|
118
120
|
- test/rbbt/test_stan.rb
|
119
121
|
- test/rbbt/vector/model/test_svm.rb
|
120
122
|
- test/rbbt/vector/test_model.rb
|
@@ -137,8 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
139
|
- !ruby/object:Gem::Version
|
138
140
|
version: '0'
|
139
141
|
requirements: []
|
140
|
-
|
141
|
-
rubygems_version: 2.6.13
|
142
|
+
rubygems_version: 3.0.6
|
142
143
|
signing_key:
|
143
144
|
specification_version: 4
|
144
145
|
summary: Data-mining and statistics
|
@@ -149,6 +150,7 @@ test_files:
|
|
149
150
|
- test/rbbt/statistics/test_fisher.rb
|
150
151
|
- test/rbbt/statistics/test_fdr.rb
|
151
152
|
- test/rbbt/statistics/test_hypergeometric.rb
|
153
|
+
- test/rbbt/test_ml_task.rb
|
152
154
|
- test/rbbt/vector/test_model.rb
|
153
155
|
- test/rbbt/vector/model/test_svm.rb
|
154
156
|
- test/rbbt/test_stan.rb
|