summaryrefslogtreecommitdiff
path: root/cv/scripts/CV_ds_pctype_algo_rseed.rb
blob: 36adb6fa62745e78ad18a0feb689e3c9345e0c01 (plain)
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 10-fold crossvalidation
# # Author: Andreas Maunz, David Vorgrimmler
# # @params: Dataset_name(see dataset_nestle.yaml), pc_type(electronic,cpsa or constitutional ... or nil to disable), prediction_algorithm(local_mlr_prop or local_svm_regression ...)

if ARGV.size != 4 
  puts "Args: ds_name, pc_type, algo, random_seed"
  puts ARGV.size
  exit
end

ds_file = "datasets.yaml"
pwd=`pwd`
path = "#{pwd.chop}/../data/#{ds_file}"
if File.exists?(path)
  puts "#{ds_file} exists"
else
  puts "#{ds_file} does not exist."
  exit
end

require 'rubygems'
require 'opentox-ruby'
require 'yaml'

subjectid = nil

ds_name = ARGV[0] # e.g. MOU
pc_type = ARGV[1] # e.g. electronic,cpsa or nil to disable
algo = ARGV[2]    # e.g. local_svm_regression, local_mlr_prop
r_seed = ARGV[3]  # 1, 2, ..., 10

ds = YAML::load_file("../data/datasets.yaml")
ds_uri = ds[ds_name]["dataset"]
pc_ds_uri = ds[ds_name][pc_type]

algo_params = "prediction_algorithm=#{algo}"
algo_params += ";pc_type=#{pc_type}" unless pc_type == "nil" 
algo_params += ";feature_dataset_uri=#{pc_ds_uri}" unless pc_type == "nil" 
puts algo_params.to_yaml

prediction_feature = OpenTox::Dataset.find(ds_uri).features.keys.first


# Ready
cv_args = {}
cv_args[:dataset_uri] = ds_uri
cv_args[:prediction_feature] = prediction_feature
cv_args[:algorithm_uri] = "http://toxcreate3.in-silico.ch:80XX/algorithm/lazar"
cv_args[:algorithm_params] = algo_params
cv_args[:stratified] = false
cv_args[:random_seed] = r_seed
puts cv_args.to_yaml

#cv = OpenTox::Crossvalidation.create(cv_args).uri
#puts cv

#cvr = OpenTox::CrossvalidationReport.create( cv , subjectid).uri
#puts cvr