summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2016-05-09 15:44:29 +0200
committerChristoph Helma <helma@in-silico.ch>2016-05-09 15:44:29 +0200
commitc1be8fe66f640d44dbbc9bfe5212733994bfb9c5 (patch)
tree42758f48d01958286dd9c6ef02f1669a5b6abdbd
parent611bac891177f8d9185d45486dd574b6ef4d1912 (diff)
physchem crossvalidation fixed, test_compound_descriptor_parameters assertions fixed
-rw-r--r--lib/regression.rb2
-rw-r--r--test/descriptor.rb13
-rw-r--r--test/validation.rb2
3 files changed, 14 insertions, 3 deletions
diff --git a/lib/regression.rb b/lib/regression.rb
index 691f903..2eaae73 100644
--- a/lib/regression.rb
+++ b/lib/regression.rb
@@ -94,7 +94,7 @@ module OpenTox
data_frame[0][i] = act
n["tanimoto"] ? weights << n["tanimoto"] : weights << 1.0 # TODO cosine ?
neighbor.physchem_descriptors.each do |pid,values|
- values = [values] if values.is_a? Float
+ values = [values] unless values.is_a? Array
values.uniq!
warn "More than one value for '#{Feature.find(pid).name}': #{values.join(', ')}. Using the median." unless values.size == 1
j = pc_ids.index(pid)+1
diff --git a/test/descriptor.rb b/test/descriptor.rb
index 7c2cf8b..cd0c1ff 100644
--- a/test/descriptor.rb
+++ b/test/descriptor.rb
@@ -63,10 +63,21 @@ class DescriptorTest < MiniTest::Test
end
def test_compound_descriptor_parameters
+ PhysChem.descriptors
c = OpenTox::Compound.from_smiles "CC(=O)CC(C)C#N"
result = c.physchem [ "Openbabel.logP", "Cdk.AtomCount.nAtom", "Joelib.LogP" ].collect{|d| PhysChem.find_or_create_by(:name => d)}
assert_equal 3, result.size
- assert_equal [1.12518, 17.0, 2.65908], result.values.collect{|v| v.round 5}
+ result.each do |fid,v|
+ feature = Feature.find(fid)
+ case feature.name
+ when "Openbabel.logP"
+ assert_equal 1.12518, v.round(5)
+ when "Cdk.AtomCount.nAtom"
+ assert_equal 17.0, v.round(5)
+ when "Joelib.LogP"
+ assert_equal 2.65908, v.round(5)
+ end
+ end
end
end
diff --git a/test/validation.rb b/test/validation.rb
index 8ebb52c..ed19fee 100644
--- a/test/validation.rb
+++ b/test/validation.rb
@@ -17,7 +17,7 @@ class ValidationTest < MiniTest::Test
model = Model::LazarRegression.create dataset.features.first, dataset
cv = RegressionCrossValidation.create model
assert cv.rmse < 1.5, "RMSE #{cv.rmse} should be larger than 1.5, this may occur due to an unfavorable training/test set split"
- assert cv.mae < 1, "MAE #{cv.mae} should be larger than 1, this may occur due to an unfavorable training/test set split"
+ assert cv.mae < 1, "MAE #{cv.mae} should be smaller than 1, this may occur due to an unfavorable training/test set split"
end
# parameters