summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormguetlein <martin.guetlein@gmail.com>2010-05-18 12:09:05 +0200
committermguetlein <martin.guetlein@gmail.com>2010-05-18 12:09:05 +0200
commit0522e88ac854e573916653cba92a76f1faa47191 (patch)
tree966454d3619c8e21b7d977e28347f42a33d3eeb9
parent6894b1ca551a8a1d430a3212311e7fe8cadc03b3 (diff)
some report design changes, reload when creating validation
-rw-r--r--report/plot_factory.rb4
-rw-r--r--report/report_factory.rb7
-rw-r--r--report/validation_data.rb13
-rw-r--r--report/xml_report.rb6
-rw-r--r--validation/validation_service.rb1
5 files changed, 23 insertions, 8 deletions
diff --git a/report/plot_factory.rb b/report/plot_factory.rb
index c5ea59f..e1fefeb 100644
--- a/report/plot_factory.rb
+++ b/report/plot_factory.rb
@@ -35,7 +35,7 @@ module Reports
tp_rates = []
attribute_values.each do |value|
data = transform_predictions(validation_set.filter({split_set_attribute => value}), class_value, false)
- names << value
+ names << value.to_s
fp_rates << data[:fp_rate][0]
tp_rates << data[:tp_rate][0]
end
@@ -169,7 +169,7 @@ module Reports
end
end
tp_fp_rates = get_tp_fp_rates(sum_roc_values)
- names << "all"
+ names << nil # "all"
fp_rate << tp_fp_rates[:fp_rate]
tp_rate << tp_fp_rates[:tp_rate]
faint << false
diff --git a/report/report_factory.rb b/report/report_factory.rb
index 366df29..dcc7b13 100644
--- a/report/report_factory.rb
+++ b/report/report_factory.rb
@@ -10,6 +10,7 @@ VAL_ATTR_REGR = [ :root_mean_squared_error, :mean_absolute_error, :r_square ]
VAL_ATTR_BAR_PLOT_CLASS = [ :accuracy, :weighted_area_under_roc, :area_under_roc, :f_measure, :true_positive_rate, :true_negative_rate ]
VAL_ATTR_BAR_PLOT_REGR = [ :root_mean_squared_error, :mean_absolute_error, :r_square ]
+
# = Reports::ReportFactory
#
# creates various reports (Reports::ReportContent)
@@ -88,8 +89,8 @@ module Reports::ReportFactory
if (validation_set.all_classification?)
report.add_section_result(merged, VAL_ATTR_CV+VAL_ATTR_CLASS-[:crossvalidation_fold],"Mean Results","Mean Results")
- report.add_section_roc_plot(validation_set, nil, nil, "roc-plot.svg", nil, nil, "Roc plot")
- report.add_section_roc_plot(validation_set, nil, :crossvalidation_fold, "roc-plot-folds.svg", nil, nil, "Roc plots for folds")
+ report.add_section_roc_plot(validation_set, nil, nil, "roc-plot.svg", "Roc Plot", nil, "Roc plot")
+ report.add_section_roc_plot(validation_set, nil, :crossvalidation_fold, "roc-plot-folds.svg", "Roc Plot", nil, "Roc plots for folds")
#validation_set.first.get_prediction_feature_values.each do |class_value|
#report.add_section_roc_plot(validation_set, class_value, nil, "roc-plot-"+class_value+".svg")
#end
@@ -283,7 +284,7 @@ class Reports::ReportContent
section_text=nil,
image_title=nil,
image_caption=nil)
-
+
if class_value
section_text = "This section contains the roc plot for class '"+class_value+"'." unless section_text
image_title = "Roc Plot for class-value '"+class_value+"'" unless image_title
diff --git a/report/validation_data.rb b/report/validation_data.rb
index 3f96cc8..d87e491 100644
--- a/report/validation_data.rb
+++ b/report/validation_data.rb
@@ -3,6 +3,17 @@
VAL_ATTR_VARIANCE = [ :area_under_roc, :percent_correct, :root_mean_squared_error, :mean_absolute_error, :r_square, :accuracy ]
VAL_ATTR_RANKING = [ :area_under_roc, :percent_correct, :true_positive_rate, :true_negative_rate, :accuracy ]
+ATTR_NICE_NAME = {}
+
+class String
+ def nice_attr()
+ if ATTR_NICE_NAME.has_key?(self)
+ return ATTR_NICE_NAME[self]
+ else
+ return self.to_s.gsub(/_id$/, "").gsub(/_/, " ").capitalize
+ end
+ end
+end
class Object
@@ -238,7 +249,7 @@ module Reports
#
def to_array(attributes, remove_nil_attributes=true, true_class_value=nil)
array = Array.new
- array.push(attributes)
+ array.push(attributes.collect{|a| a.to_s.nice_attr})
attribute_not_nil = Array.new(attributes.size)
@validations.each do |v|
index = 0
diff --git a/report/xml_report.rb b/report/xml_report.rb
index f1980a8..a477cd8 100644
--- a/report/xml_report.rb
+++ b/report/xml_report.rb
@@ -91,7 +91,9 @@ module Reports
figure << Reports::XMLReportUtil.text_element("title", title)
media = Element.new("mediaobject")
image = Element.new("imageobject")
- imagedata = Reports::XMLReportUtil.attribute_element("imagedata",{"contentwidth" => "100%", "fileref" => path, "format"=>filetype})
+ imagedata = Reports::XMLReportUtil.attribute_element("imagedata",
+ {"fileref" => path, "format"=>filetype, "contentwidth" => "6in", "contentdepth"=> "4in"
+ })#"width" => "6in", "height" => "5in"}) #"contentwidth" => "100%"})
#imagedata = Reports::XMLReportUtil.attribute_element("imagedata",{"width" => "6in", "fileref" => path, "format"=>filetype})
@resource_path_elements[imagedata] = "fileref"
image << imagedata
@@ -113,7 +115,7 @@ module Reports
values = transpose ? table_values.transpose : table_values
- table = Reports::XMLReportUtil.attribute_element("table",{"frame" => "top", "colsep" => 0, "rowsep" => 0})
+ table = Reports::XMLReportUtil.attribute_element("table",{"frame" => "none", "colsep" => 1, "rowsep" => 1 })
table << Reports::XMLReportUtil.text_element("title", title)
diff --git a/validation/validation_service.rb b/validation/validation_service.rb
index 9c73215..6ac7415 100644
--- a/validation/validation_service.rb
+++ b/validation/validation_service.rb
@@ -44,6 +44,7 @@ module Validation
unless save
raise "error saving validation "+errors.inspect
end
+ reload
raise "internal error, validation-id not set "+to_yaml if @id==nil
end
update :uri => $sinatra.url_for("/"+@id.to_s, :full)