summaryrefslogtreecommitdiff
path: root/create_prediction_models.rb
blob: 9c3995f4b96b7d00ce5f1682c55620dd0f1eb3dd (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
ENV["LAZAR_ENV"] = "production"
require_relative '../lazar/lib/lazar'
#require 'lazar'
include OpenTox
#$mongo.database.drop
#$gridfs = $mongo.database.fs # recreate GridFS indexes

=begin
# classification models
Dir["classification/*csv"].each do |file|
  unless file.match(/hamster/)
    Model::Validation.from_csv_file file
  end
end
=end

#=begin
# regression models
Dir["regression/*log10.csv"].each do |file|
  unless file.match(/fathead/)#until dublicates not cleared
    Model::Validation.from_csv_file file
  end
end
#=end

## nano-lazar
=begin

# creates 3 models: one with physchem, one with proteomics, one with fingerprints
feature_categories = ["fingerprint", "P-CHEM", "Proteomics"]

feature_categories.each do |category|
  if category == "fingerprint"
		algorithms = {
			:descriptors => { :method => "fingerprint", :type => "MP2D", },
			:feature_selection => nil,
			:similarity => {
				:method => "Algorithm::Similarity.tanimoto",
				:min => 0.1
			}
		}
		
		OpenTox::Model::Validation.from_enanomapper algorithms: algorithms
	else
		algorithms = {
			:descriptors => {
				:method => "properties",
				:categories => (category.is_a?(Array) ? [category].flatten : [category]),
			},
			:similarity => {
				:method => "Algorithm::Similarity.weighted_cosine",
				:min => 0.5
			},
			:prediction => {
				:method => "Algorithm::Caret.rf",
			},
			:feature_selection => {
				:method => "Algorithm::FeatureSelection.correlation_filter",
			},
		}

		OpenTox::Model::Validation.from_enanomapper algorithms: algorithms
	end
end
=end

# save local dump but git ignored
`mongodump -h 127.0.0.1 -d production`

# build reports and users dump
eval File.read('./lazar_validation_reports.rb')

# restore
#`mongorestore --host 127.0.0.1`