summaryrefslogtreecommitdiff
path: root/lib/ot_predictions.rb
diff options
context:
space:
mode:
authorMartin Gütlein <martin.guetlein@gmail.com>2010-04-14 11:33:44 +0200
committerMartin Gütlein <martin.guetlein@gmail.com>2010-04-14 11:33:44 +0200
commita35e4d1540b74d6687529b43c1c6e5b85deb680e (patch)
tree17e4a91fedc7b7e43eeedd5fc7e6911358ee515c /lib/ot_predictions.rb
parentb3e888fea0c750ca2c10c5b12bcc12c877aa1813 (diff)
removing class feature in test-datsets, introduced test_class_dataset
Diffstat (limited to 'lib/ot_predictions.rb')
-rw-r--r--lib/ot_predictions.rb21
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/ot_predictions.rb b/lib/ot_predictions.rb
index 9e6f5c9..0176dcf 100644
--- a/lib/ot_predictions.rb
+++ b/lib/ot_predictions.rb
@@ -15,10 +15,11 @@ module Lib
return @compounds[instance_index]
end
- def initialize(is_classification, test_dataset_uri, prediction_feature, prediction_dataset_uri, predicted_variable)
+ def initialize(is_classification, test_dataset_uri, test_target_datset_uri, prediction_feature, prediction_dataset_uri, predicted_variable)
LOGGER.debug("loading prediciton via test-dateset:'"+test_dataset_uri.to_s+
- "' and prediction-dataset:'"+prediction_dataset_uri.to_s+
+ "', test-target-datset:'"+test_target_datset_uri.to_s+
+ "', prediction-dataset:'"+prediction_dataset_uri.to_s+
"', prediction_feature: '"+prediction_feature.to_s+"' "+
"', predicted_variable: '"+predicted_variable.to_s+"'")
@@ -31,7 +32,19 @@ module Lib
test_dataset = OpenTox::Dataset.find test_dataset_uri
raise "test dataset not found: '"+test_dataset_uri.to_s+"'" unless test_dataset
- raise "test dataset feature not found: '"+prediction_feature.to_s+"', available features: "+test_dataset.features.inspect if test_dataset.features.index(prediction_feature)==nil
+
+ if test_target_datset_uri == nil || test_target_datset_uri==test_dataset_uri
+ test_class_dataset = test_dataset
+ else
+ test_class_dataset = OpenTox::Dataset.find test_target_datset_uri
+ raise "test target datset not found: '"+test_target_datset_uri.to_s+"'" unless test_class_dataset
+ if CHECK_VALUES
+ test_dataset.compounds.each do |c|
+ raise "test compound not found on test class dataset "+c.to_s unless test_class_dataset.compounds.include?(c)
+ end
+ end
+ end
+ raise "test dataset feature not found: '"+prediction_feature.to_s+"', available features: "+test_class_dataset.features.inspect if test_class_dataset.features.index(prediction_feature)==nil
@compounds = test_dataset.compounds
LOGGER.debug "test dataset size: "+@compounds.size.to_s
@@ -41,7 +54,7 @@ module Lib
actual_values = []
@compounds.each do |c|
- value = test_dataset.get_value(c, prediction_feature)
+ value = test_class_dataset.get_value(c, prediction_feature)
if is_classification
value = value.to_s unless value==nil