1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# Do a five times 10-fold crossvalidation
# # Author: Andreas Maunz, David Vorgrimmler
# # @params: CSV-File, Method (LAST, BBRC), Minimum Frequency
require 'rubygems'
require 'opentox-ruby'
require 'lib/cv_am.rb'
subjectid = nil
if ARGV.size != 1
puts
puts "Error! Arguments: <algorithm_params> in the form p1=v1;p2=v2;...;pn=vn"
exit 1
end
# Arguments for lib/cv.rb: file_or_dataset_uri feature_generation min_frequency min_chisq_significance backbone stratified random_seed prediction_algorithm local_svm_kernel nr_hits conf_stdev
position_mapper={
"dataset_uri" => 0,
"feature_generation_uri" => 1,
"min_frequency" => 2,
"min_chisq_significance" => 3,
"backbone" => 4,
"stratified" => 5,
"random_seed" => 6,
"prediction_algorithm" => 7,
"local_svm_kernel" => 8,
"nr_hits" => 9,
"conf_stdev" => 10
}
param_str=$ARGV[0]
puts param_str
params = Array.new(position_mapper.size,"")
param_str.split(";").each { |param|
k,v = param.split("=")
params[position_mapper[k]] = v
}
params[5]="false" # stratified
exception_config = YAML.load_file("exceptions_config.yaml")
if ! exception_config[params[0]].nil?
exception_config[params[0]].each { |k,v|
puts "Setting exception: #{k} => #{v}"
params[position_mapper[k]] = v
}
end
for i in 1..5
begin
puts
puts "Round #{i.to_s}."
params[6]=i # random seed
cv(params)
rescue Exception => e
puts "Error in 5xCV: #{e.message}: #{e.backtrace}"
end
end
|