summaryrefslogtreecommitdiff
path: root/report
diff options
context:
space:
mode:
authorMartin Gütlein <martin.guetlein@gmail.com>2010-03-08 17:01:23 +0100
committerMartin Gütlein <martin.guetlein@gmail.com>2010-03-08 17:01:23 +0100
commit9c41e91c6a6067d8b254e0ef5da66c752fabdb4d (patch)
tree74d4e9702bed59f2d6d5b3fd035e88020dba9f79 /report
parente93ada015dbe91cff5b72eb8628c4f52814e3bdb (diff)
fixed: percent float instead of int, sum of number counts for cv
Diffstat (limited to 'report')
-rw-r--r--report/plot_factory.rb3
-rw-r--r--report/report_factory.rb2
-rw-r--r--report/report_test.rb9
-rw-r--r--report/validation_data.rb91
-rw-r--r--report/xml_report.rb2
-rw-r--r--report/xml_report_util.rb1
6 files changed, 20 insertions, 88 deletions
diff --git a/report/plot_factory.rb b/report/plot_factory.rb
index c1a731f..afe98de 100644
--- a/report/plot_factory.rb
+++ b/report/plot_factory.rb
@@ -109,10 +109,11 @@ module Reports
svg_out_file ? show = "-o" : show = ""
(title and title.length > 0) ? tit = '-t "'+title+'"' : tit = ""
#title = "-t \""+ranking_value_prop+"-Ranking ("+comparables.size.to_s+" "+comparable_prop+"s, "+num_groups.to_s+" "+ranking_group_prop+"s, p < "+p.to_s+")\" "
-
+
cmd = "java -jar "+ENV['RANK_PLOTTER_JAR']+" "+tit+" -c '"+
comparables_array.join(",")+"' -r '"+ranks_array.join(",")+"' "+conf+" "+show #+" > /home/martin/tmp/test.svg"
#puts "\nplotting: "+cmd
+ LOGGER.debug "Plotting ranks: "+cmd.to_s
res = ""
IO.popen(cmd) do |f|
diff --git a/report/report_factory.rb b/report/report_factory.rb
index a522901..7484eb1 100644
--- a/report/report_factory.rb
+++ b/report/report_factory.rb
@@ -118,7 +118,7 @@ module Reports::ReportFactory
Reports::Util.check_group_matching(dataset_grouping, [:algorithm_uri])
#merged = validation_set.merge([:algorithm_uri, :dataset_uri])
- report = Reports::ReportContent.new("Algorithm comparison report Many datasets")
+ report = Reports::ReportContent.new("Algorithm comparison report - Many datasets")
if (validation_set.first.classification?)
report.add_section_result(validation_set,[:algorithm_uri, :test_dataset_uri]+VAL_ATTR_CLASS,"Mean Results","Mean Results")
diff --git a/report/report_test.rb b/report/report_test.rb
index a75dd76..3960856 100644
--- a/report/report_test.rb
+++ b/report/report_test.rb
@@ -22,9 +22,14 @@ class Reports::ApplicationTest < Test::Unit::TestCase
#get uri
#get '/report/validation/1',nil,'HTTP_ACCEPT' => "text/html"
- post '/report/validation/1/format_html',:css_style_sheet=>"http://apps.ideaconsult.net:8180/ToxPredict/style/global.css"
+ #post '/report/validation/1/format_html',:css_style_sheet=>"http://apps.ideaconsult.net:8180/ToxPredict/style/global.css"
+
+ post 'http://ot.validation.de/report/crossvalidation',:validation_uris=>"http://ot.validation.de/crossvalidation/1"
+ uri = last_response.body.to_s
+
+ #post uri.to_s+'/format_html',:css_style_sheet=>"http://apps.ideaconsult.net:8180/ToxPredict/style/global.css"
+ #puts last_response.body.to_s.gsub(/\n.*/,"")
- puts last_response.body.to_s.gsub(/\n.*/,"")
end
#
# def test_webservice
diff --git a/report/validation_data.rb b/report/validation_data.rb
index a2b8905..c164674 100644
--- a/report/validation_data.rb
+++ b/report/validation_data.rb
@@ -48,7 +48,7 @@ module Reports
class Validation
@@validation_access = Reports::ValidationDB.new
-
+
# for overwriting validation source (other than using webservices)
def self.reset_validation_access(validation_access)
@@validation_access = validation_access
@@ -65,11 +65,10 @@ module Reports
VAL_ATTR_RANKING.collect{ |a| (a.to_s+"_ranking").to_sym }
@@validation_attributes.each{ |a| attr_accessor a }
- attr_reader :predictions, :merge_count
+ attr_reader :predictions
def initialize(uri = nil)
@@validation_access.init_validation(self, uri) if uri
- @merge_count = 1
end
# returns/creates predictions, cache to save rest-calls/computation time
@@ -109,86 +108,8 @@ module Reports
def clone_validation
new_val = clone
VAL_ATTR_VARIANCE.each { |a| new_val.send((a.to_s+"_variance=").to_sym,nil) }
- new_val.set_merge_count(1)
return new_val
end
-
- # merges this validation and another validation object to a new validation object
- # * v1.att = "a", v2.att = "a" => r.att = "a"
- # * v1.att = "a", v2.att = "b" => r.att = "a / b"
- # * v1.att = "1", v2.att = "2" => r.att = "1.5"
- # * the attributes in __equal_attributes__ are assumed to be equal
- #
- # call-seq:
- # merge( validation, equal_attributes) => Reports::Validation
- #
- def merge_validation( validation, equal_attributes )
-
- new_validation = Reports::Validation.new
- # validation cannot be merged before
- raise "not working" if validation.merge_count > 1
-
- @@validation_attributes.each do |a|
- next if a.to_s =~ /_variance$/
-
- if (equal_attributes.index(a) != nil)
- new_validation.send("#{a.to_s}=".to_sym, send(a))
- else
-
- compute_variance = VAL_ATTR_VARIANCE.index(a)!=nil
- old_variance = compute_variance ? send((a.to_s+"_variance").to_sym) : nil
- m = Validation::merge_value( send(a), @merge_count, compute_variance, old_variance, validation.send(a) )
-
- new_validation.send("#{a.to_s}=".to_sym, m[:value])
- new_validation.send("#{a.to_s+"_variance"}=".to_sym, m[:variance]) if compute_variance
- end
- end
-
- new_validation.set_merge_count(@merge_count + 1);
- return new_validation
- end
-
- def merge_count
- @merge_count
- end
-
- protected
- def set_merge_count(c)
- @merge_count = c
- end
-
- # merges to values (value1 and value2), value1 has weight weight1, value2 has weight 1,
- # computes variance if corresponding params are set
- #
- # return hash with merge value (:value) and :variance (if necessary)
- #
- def self.merge_value( value1, weight1, compute_variance, variance1, value2 )
-
- if (value1.is_a?(Numeric))
- value = (value1 * weight1 + value2) / (weight1 + 1).to_f;
- if compute_variance
- variance = Lib::Util::compute_variance( variance1!=nil ? variance1 : 0, weight1+1, value, value1, value2 )
- end
- elsif value1.is_a?(Array)
- raise "not yet implemented : merging arrays"
- elsif value1.is_a?(Hash)
- value = {}
- variance = {}
- value1.keys.each do |k|
- m = merge_value( value1[k], weight1, compute_variance, variance1==nil ? nil : variance1[k], value2[k] )
- value[k] = m[:value]
- variance[k] = m[:variance] if compute_variance
- end
- else
- if value1.to_s != value2.to_s
- value = value1.to_s + "/" + value2.to_s
- else
- value = value2.to_s
- end
- end
-
- {:value => value, :variance => (compute_variance ? variance : nil) }
- end
end
# = Reports:ValidationSet
@@ -327,11 +248,15 @@ module Reports
#compute grouping
grouping = Reports::Util.group(@validations, equal_attributes)
+ Lib::MergeObjects.register_merge_attributes( Reports::Validation,
+ Lib::VAL_MERGE_AVG,Lib::VAL_MERGE_SUM,Lib::VAL_MERGE_GENERAL) unless
+ Lib::MergeObjects.merge_attributes_registered?(Reports::Validation)
+
#merge
grouping.each do |g|
new_set.validations.push(g[0].clone_validation)
g[1..-1].each do |v|
- new_set.validations[-1] = new_set.validations[-1].merge_validation(v, equal_attributes)
+ new_set.validations[-1] = Lib::MergeObjects.merge_objects(new_set.validations[-1],v)
end
end
@@ -419,4 +344,4 @@ module Reports
end
-end \ No newline at end of file
+end
diff --git a/report/xml_report.rb b/report/xml_report.rb
index be66851..4b62457 100644
--- a/report/xml_report.rb
+++ b/report/xml_report.rb
@@ -1,6 +1,5 @@
require 'rexml/document'
-include REXML
ENV['REPORT_DTD'] = "docbook-xml-4.5/docbookx.dtd" unless ENV['REPORT_DTD']
#transfer to absolute path
@@ -13,6 +12,7 @@ ENV['REPORT_DTD'] = File.expand_path(ENV['REPORT_DTD']) if File.exist?(ENV['REPO
# uses Env-Variable _XMLREPORT_DTD_ to specifiy the dtd
#
class Reports::XMLReport
+ include REXML
# create new xmlreport
def initialize(title, pubdate=nil, author_firstname = nil, author_surname = nil)
diff --git a/report/xml_report_util.rb b/report/xml_report_util.rb
index 00ff608..d047421 100644
--- a/report/xml_report_util.rb
+++ b/report/xml_report_util.rb
@@ -4,6 +4,7 @@
# Utilities for XMLReport
#
module Reports::XMLReportUtil
+ include REXML
# creates a confusion matrix as array (to be used as input for Reports::XMLReport::add_table)
# input is confusion matrix as returned by Lib::Predictions.confusion_matrix