From 750c3a57db4ed5ad3ec50c7875ad3edf877727f6 Mon Sep 17 00:00:00 2001 From: mguetlein Date: Fri, 20 May 2011 10:51:18 +0200 Subject: handle confidence nil values, and fix prediction confidence sorting, improved prediction table --- lib/ot_predictions.rb | 19 +++++++++++-------- report/environment.rb | 2 ++ report/report_application.rb | 4 ++++ report/xml_report.rb | 10 +++++----- resources/error.png | Bin 0 -> 1060 bytes resources/ok.png | Bin 0 -> 976 bytes resources/ot-logo.png | Bin 0 -> 14338 bytes 7 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 resources/error.png create mode 100644 resources/ok.png create mode 100644 resources/ot-logo.png 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 diff --git a/report/environment.rb b/report/environment.rb index 59465aa..bdb4a04 100755 --- a/report/environment.rb +++ b/report/environment.rb @@ -27,6 +27,8 @@ require "report/validation_data.rb" require "report/util.rb" require "report/statistical_test.rb" +ICON_ERROR = File.join(CONFIG[:services]["opentox-validation"],"resources/error.png") +ICON_OK = File.join(CONFIG[:services]["opentox-validation"],"resources/ok.png") diff --git a/report/report_application.rb b/report/report_application.rb index 1637ead..3c8670a 100755 --- a/report/report_application.rb +++ b/report/report_application.rb @@ -23,6 +23,10 @@ get '/'+ENV['DOCBOOK_DIRECTORY']+'/:resource' do get_docbook_resource ENV['DOCBOOK_DIRECTORY']+"/"+request.env['REQUEST_URI'].split("/")[-1] end +get '/resources/:resource' do + get_docbook_resource "resources/"+request.env['REQUEST_URI'].split("/")[-1] +end + get '/report/:type/css_style_sheet/?' do perform do |rs| "@import \""+params[:css_style_sheet]+"\";" diff --git a/report/xml_report.rb b/report/xml_report.rb index b308c01..cf30e3b 100755 --- a/report/xml_report.rb +++ b/report/xml_report.rb @@ -159,16 +159,16 @@ module Reports table end - def add_image( element, url ) + def add_image( element, url ) #, scale=false ) image = Element.new("imageobject") - imagedata = Reports::XMLReportUtil.attribute_element("imagedata", - {"fileref" => url, "format"=>"PNG", "contentwidth" => "2in" }) #PENDING: do not hardcode size + params = {"fileref" => url, "format"=>"PNG"} + #params["contentwidth"] = "2in" + imagedata = Reports::XMLReportUtil.attribute_element("imagedata",params) image << imagedata element << image return image end - # adds a table to a REXML:Element, _table_values_ should be a multi-dimensional-array, returns the table as element # # call-seq: @@ -216,7 +216,7 @@ module Reports row = Element.new("row") r.each do |v| entry = Element.new("entry") - if auto_link_urls && v.to_s =~ /depict/ || v.to_s =~ /image\/png$/ #PENDING + if auto_link_urls && v.to_s =~ /depict/ || v.to_s =~ /png$/ #PENDING add_image(entry, v.to_s) elsif auto_link_urls && v.to_s =~ /^http(s?):\/\// #add_url(entry, v.to_s, v.to_s) diff --git a/resources/error.png b/resources/error.png new file mode 100644 index 0000000..e051534 Binary files /dev/null and b/resources/error.png differ diff --git a/resources/ok.png b/resources/ok.png new file mode 100644 index 0000000..31bd433 Binary files /dev/null and b/resources/ok.png differ diff --git a/resources/ot-logo.png b/resources/ot-logo.png new file mode 100644 index 0000000..248a853 Binary files /dev/null and b/resources/ot-logo.png differ -- cgit v1.2.3