diff options
author | mguetlein <martin.guetlein@gmail.com> | 2011-05-20 10:51:18 +0200 |
---|---|---|
committer | mguetlein <martin.guetlein@gmail.com> | 2011-05-20 10:51:18 +0200 |
commit | 750c3a57db4ed5ad3ec50c7875ad3edf877727f6 (patch) | |
tree | 2fd272ecfcd2a35d7ec81b0d84a386ceab213fb8 /lib | |
parent | b0ca028f1d9eaa30774f8c843c8b2ec8943247f6 (diff) |
handle confidence nil values, and fix prediction confidence sorting, improved prediction table
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/ot_predictions.rb | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/ot_predictions.rb b/lib/ot_predictions.rb index 644168f..93581d8 100755 --- a/lib/ot_predictions.rb +++ b/lib/ot_predictions.rb @@ -146,11 +146,11 @@ module Lib predicted_values << regression_value(prediction_dataset, c, no_prediction_feature ? nil : predicted_variable) end # TODO confidence_values << prediction_dataset.get_prediction_confidence(c, predicted_variable) - conf = predicted_values[count]!=nil ? 1 : 0 + conf = predicted_values[count]!=nil ? 1 : nil begin feature = prediction_dataset.data_entries[c].keys[0] feature_data = prediction_dataset.features[feature] - conf = feature_data[OT.confidence] if feature_data[OT.confidence]!=nil + conf = feature_data[OT.confidence].to_f if feature_data[OT.confidence]!=nil rescue LOGGER.warn "could not get confidence" end @@ -259,13 +259,17 @@ module Lib a << (format ? p.predicted_value(i).to_nice_s : p.predicted_value(i)) if p.feature_type=="classification" if (p.predicted_value(i)!=nil and p.actual_value(i)!=nil) - a << (p.classification_miss?(i) ? 1 : 0) + if p.classification_miss?(i) + a << (format ? ICON_ERROR : 1) + else + a << (format ? ICON_OK : 0) + end else a << nil end end if p.confidence_values_available? - conf_column = a.size + conf_column = a.size if conf_column==nil a << p.confidence_value(i) #(format ? p.confidence_value(i).to_nice_s : p.confidence_value(i)) end a << p.identifier(i) @@ -274,10 +278,10 @@ module Lib end if conf_column!=nil - res.sort!{ |x,y| y[4] <=> x[4] } + res = res.sort_by{ |n| n[conf_column] || 0 }.reverse if format res.each do |a| - a[4] = a[4].to_nice_s + a[conf_column] = a[conf_column].to_nice_s end end end @@ -291,7 +295,6 @@ module Lib res.insert(0, header) return res - end - + end end end |