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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
require_relative "setup.rb"
class NanoparticleValidationTest < MiniTest::Test
include OpenTox::Validation
def setup
@training_dataset = Dataset.where(:name => "Protein Corona Fingerprinting Predicts the Cellular Interaction of Gold and Silver Nanoparticles").first
unless @training_dataset
Import::Enanomapper.import File.join(File.dirname(__FILE__),"data","enm")
@training_dataset = Dataset.where(name: "Protein Corona Fingerprinting Predicts the Cellular Interaction of Gold and Silver Nanoparticles").first
end
@prediction_feature = @training_dataset.features.select{|f| f["name"] == 'log2(Net cell association)'}.first
end
def test_validate_default_nanoparticle_model
model = Model::Lazar.create training_dataset: @training_dataset, prediction_feature: @prediction_feature
cv = CrossValidation.create model
p cv
p cv.rmse
p cv.r_squared
#File.open("tmp.pdf","w+"){|f| f.puts cv.correlation_plot}
refute_nil cv.r_squared
refute_nil cv.rmse
end
def test_validate_pls_nanoparticle_model
algorithms = {
:descriptors => {
:method => "properties",
:categories => ["P-CHEM"]
},
:prediction => {:method => 'Algorithm::Caret.pls' },
}
model = Model::Lazar.create prediction_feature: @prediction_feature, training_dataset: @training_dataset, algorithms: algorithms
assert_equal "Algorithm::Caret.pls", model.algorithms[:prediction][:method]
cv = CrossValidation.create model
p cv.rmse
p cv.r_squared
refute_nil cv.r_squared
refute_nil cv.rmse
end
def test_validate_proteomics_pls_nanoparticle_model
algorithms = {
:descriptors => {
:method => "properties",
:categories => ["Proteomics"]
},
:prediction => {:method => 'Algorithm::Caret.pls' },
}
model = Model::Lazar.create prediction_feature: @prediction_feature, training_dataset: @training_dataset, algorithms: algorithms
assert_equal "Algorithm::Caret.pls", model.algorithms[:prediction][:method]
cv = CrossValidation.create model
p cv.rmse
p cv.r_squared
refute_nil cv.r_squared
refute_nil cv.rmse
end
def test_validate_all_default_nanoparticle_model
algorithms = {
:descriptors => {
:method => "properties",
:categories => ["Proteomics","P-CHEM"]
},
}
model = Model::Lazar.create prediction_feature: @prediction_feature, training_dataset: @training_dataset, algorithms: algorithms
cv = CrossValidation.create model
p cv.rmse
p cv.r_squared
refute_nil cv.r_squared
refute_nil cv.rmse
end
def test_nanoparticle_fingerprint_model
algorithms = {
:descriptors => {
:method => "fingerprint",
:type => "MP2D",
},
:similarity => {
:method => "Algorithm::Similarity.tanimoto",
:min => 0.1
},
:feature_selection => nil
}
model = Model::Lazar.create prediction_feature: @prediction_feature, training_dataset: @training_dataset, algorithms: algorithms
cv = CrossValidation.create model
p cv.rmse
p cv.r_squared
refute_nil cv.r_squared
refute_nil cv.rmse
end
def test_nanoparticle_fingerprint_weighted_average_model
algorithms = {
:descriptors => {
:method => "fingerprint",
:type => "MP2D",
},
:similarity => {
:method => "Algorithm::Similarity.tanimoto",
:min => 0.1
},
:prediction => { :method => "OpenTox::Algorithm::Regression.weighted_average" },
:feature_selection => nil
}
model = Model::Lazar.create prediction_feature: @prediction_feature, training_dataset: @training_dataset, algorithms: algorithms
cv = CrossValidation.create model
p cv.rmse
p cv.r_squared
refute_nil cv.r_squared
refute_nil cv.rmse
end
def test_nanoparticle_fingerprint_model_with_feature_selection
algorithms = {
:descriptors => {
:method => "fingerprint",
:type => "MP2D",
},
:similarity => {
:method => "Algorithm::Similarity.tanimoto",
:min => 0.1
},
}
model = Model::Lazar.create prediction_feature: @prediction_feature, training_dataset: @training_dataset, algorithms: algorithms
cv = CrossValidation.create model
p cv.rmse
p cv.r_squared
refute_nil cv.r_squared
refute_nil cv.rmse
end
end
|