diff options
author | mguetlein <martin.guetlein@gmail.com> | 2011-05-06 20:05:04 +0200 |
---|---|---|
committer | mguetlein <martin.guetlein@gmail.com> | 2011-05-06 20:05:04 +0200 |
commit | 02220bab22c0ea60394b71dfba536284ada17eb8 (patch) | |
tree | a949adc0b870c1c98a87f12f283f56803e8c18bc /lib/ot_predictions.rb | |
parent | 710976325cd0e23297e07c0a2f2460573287a49b (diff) |
validation utilizes/requires acceptValue for classification
Diffstat (limited to 'lib/ot_predictions.rb')
-rwxr-xr-x | lib/ot_predictions.rb | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/ot_predictions.rb b/lib/ot_predictions.rb index 5033425..1fd601c 100755 --- a/lib/ot_predictions.rb +++ b/lib/ot_predictions.rb @@ -54,13 +54,20 @@ module Lib @compounds = test_dataset.compounds LOGGER.debug "test dataset size: "+@compounds.size.to_s raise "test dataset is empty "+test_dataset_uri.to_s unless @compounds.size>0 - class_values = feature_type=="classification" ? OpenTox::Feature.find(prediction_feature, subjectid).domain : nil + + if feature_type=="classification" + accept_values = test_target_dataset.features[prediction_feature][OT.acceptValue] + raise "'"+OT.acceptValue.to_s+"' missing/invalid for feature '"+prediction_feature.to_s+"' in dataset '"+ + test_target_dataset_uri.to_s+"', acceptValues are: '"+accept_values.inspect+"'" if accept_values==nil or accept_values.length<2 + else + accept_values=nil + end actual_values = [] @compounds.each do |c| case feature_type when "classification" - actual_values << classification_value(test_target_dataset, c, prediction_feature, class_values) + actual_values << classification_value(test_target_dataset, c, prediction_feature, accept_values) when "regression" actual_values << regression_value(test_target_dataset, c, prediction_feature) end @@ -108,7 +115,7 @@ module Lib case feature_type when "classification" # TODO: remove LAZAR_PREDICTION_DATASET_HACK - predicted_values << classification_value(prediction_dataset, c, no_prediction_feature ? nil : predicted_variable, class_values) + predicted_values << classification_value(prediction_dataset, c, no_prediction_feature ? nil : predicted_variable, accept_values) when "regression" predicted_values << regression_value(prediction_dataset, c, no_prediction_feature ? nil : predicted_variable) end @@ -126,7 +133,7 @@ module Lib end task.progress(80) if task # loaded predicted values and confidence - super(predicted_values, actual_values, confidence_values, feature_type, class_values) + super(predicted_values, actual_values, confidence_values, feature_type, accept_values) raise "illegal num compounds "+num_info if @compounds.size != @predicted_values.size task.progress(100) if task # done with the mathmatics end @@ -143,11 +150,11 @@ module Lib end end - def classification_value(dataset, compound, feature, class_values) + def classification_value(dataset, compound, feature, accept_values) v = value(dataset, compound, feature) - i = class_values.index(v) - raise "illegal class_value of prediction (value is '"+v.to_s+"', class is '"+v.class.to_s+"'), possible values are "+ - class_values.inspect unless v==nil or i!=nil + i = accept_values.index(v.to_s) + raise "illegal class_value of prediction (value is '"+v.to_s+"'), accept values are "+ + accept_values.inspect unless v==nil or i!=nil i end |