diff options
author | Martin Gütlein <martin.guetlein@gmail.com> | 2010-02-26 15:13:44 +0100 |
---|---|---|
committer | Martin Gütlein <martin.guetlein@gmail.com> | 2010-02-26 15:13:44 +0100 |
commit | e2b814301c323bc787ad9d75eceb786e3cb7dde9 (patch) | |
tree | 21c668db2a956796302a97d1a41fb59c38783cf0 /report/plot_factory.rb | |
parent | bb3f0d747876b59e6c2eaa24441d5690c2655d3b (diff) |
replacing r bar plot with ruby-plot gem
Diffstat (limited to 'report/plot_factory.rb')
-rw-r--r-- | report/plot_factory.rb | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/report/plot_factory.rb b/report/plot_factory.rb index 3973989..d2884e3 100644 --- a/report/plot_factory.rb +++ b/report/plot_factory.rb @@ -39,13 +39,40 @@ module Reports fp_rates << data[:fp_rate][0] tp_rates << data[:tp_rate][0] end - Svg_Roc_Plot::plot(out_file, "ROC-Plot", "False positive rate", "True Positive Rate", names, fp_rates, tp_rates ) + RubyPlot::plot_lines(out_file, "ROC-Plot", "False positive rate", "True Positive Rate", names, fp_rates, tp_rates ) else data = transform_predictions(validation_set, class_value, show_single_curves) - Svg_Roc_Plot::plot(out_file, "ROC-Plot", "False positive rate", "True Positive Rate", data[:names], data[:fp_rate], data[:tp_rate], data[:faint] ) + RubyPlot::plot_lines(out_file, "ROC-Plot", "False positive rate", "True Positive Rate", data[:names], data[:fp_rate], data[:tp_rate], data[:faint] ) end end + def self.create_bar_plot( out_file, validation_set, class_value, title_attribute, value_attributes ) + + LOGGER.debug "creating bar plot, out-file:"+out_file.to_s + + data = [] + validation_set.validations.each do |v| + values = [] + value_attributes.collect do |a| + value = v.send(a) + if value.is_a?(Hash) + raise "bar plot value is hash, but no entry for class-value ("+class_value.to_s+")" unless value.key?(class_value) + value = value[class_value] + end + values.push(value) + end + data << [v.send(title_attribute).to_s] + values + end + + labels = value_attributes.collect{|a| a.to_s.gsub("_","-")} + + LOGGER.debug "bar plot labels: "+labels.inspect + LOGGER.debug "bar plot data: "+data.inspect + + RubyPlot::plot_bars('Bar plot', labels, data, out_file) + + end + def self.create_ranking_plot( svg_out_file, validation_set, compare_attribute, equal_attribute, rank_attribute ) |