summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormguetlein <martin.guetlein@gmail.com>2011-05-31 22:26:34 +0200
committermguetlein <martin.guetlein@gmail.com>2011-05-31 22:26:34 +0200
commitb542cfbd54901ad86d60fed03c8a05f9151f7616 (patch)
tree690c5633ef3d570699f720afdb7b708be0acc6af
parent43e211e2765ea3e929d6e146a11cdd8d5f87df30 (diff)
quit r instance after statistical test, will hopefully solve timeout problem
-rwxr-xr-xreport/environment.rb4
-rwxr-xr-xreport/report_content.rb1
-rw-r--r--report/statistical_test.rb28
3 files changed, 25 insertions, 8 deletions
diff --git a/report/environment.rb b/report/environment.rb
index a7d454f..72320a0 100755
--- a/report/environment.rb
+++ b/report/environment.rb
@@ -1,13 +1,11 @@
['rubygems', 'logger', 'fileutils', 'sinatra', 'sinatra/url_for', 'rest_client',
- 'yaml', 'fileutils', 'mime/types', 'abbrev', 'rinruby',
+ 'yaml', 'fileutils', 'mime/types', 'abbrev',
'rexml/document', 'ruby-plot', 'opentox-ruby' ].each do |g|
require g
end
gem 'ruby-plot', "~>0.5.0"
-#R.quit
-
module Reports
end
diff --git a/report/report_content.rb b/report/report_content.rb
index d151a7d..30118cf 100755
--- a/report/report_content.rb
+++ b/report/report_content.rb
@@ -48,6 +48,7 @@ class Reports::ReportContent
@xml_report.add_table(section_test, test_attribute.to_s+", significance-level: "+level.to_s+", num results: "+
test_matrix[:num_results].to_s, table, true, true)
end
+ Reports::ReportStatisticalTest.quit_r
end
def add_predictions( validation_set,
diff --git a/report/statistical_test.rb b/report/statistical_test.rb
index 1e586e2..bee6241 100644
--- a/report/statistical_test.rb
+++ b/report/statistical_test.rb
@@ -1,29 +1,35 @@
#require "rubygems"
#require "rinruby"
-#R.quit
module LIB
class StatisticalTest
- @@r = RinRuby.new(true,false)
-
# -1 -> array1 < array2
# 0 -> not difference
# 1 -> array2 > array1
#
def self.pairedTTest(array1, array2, significance_level=0.95)
+
+ @@r = RinRuby.new(true,false) unless defined?(@@r) and @@r
@@r.assign "v1",array1
@@r.assign "v2",array2
@@r.eval "ttest = t.test(v1,v2,paired=T)"
t = @@r.pull "ttest$statistic"
p = @@r.pull "ttest$p.value"
- #@@r.quit
if (1-significance_level > p)
t
else
0
end
end
+
+ def self.quit_r
+ begin
+ @@r.quit
+ @@r = nil
+ rescue
+ end
+ end
end
end
@@ -68,9 +74,21 @@ module Reports
LOGGER.debug "paired-t-testing "+attribute.to_s+" "+array1.inspect+" vs "+array2.inspect
LIB::StatisticalTest.pairedTTest(array1, array2, significance_level)
end
+
+ def self.quit_r
+ LIB::StatisticalTest.quit_r
+ end
+
end
end
-#puts LIB::StatisticalTest.pairedTTest([1,2,3],[2,3,3])
+#t1 = Time.new
+#10.times do
+# puts LIB::StatisticalTest.pairedTTest([1,2,3,4,5,12,4,2],[2,3,3,3,56,3,4,5])
+#end
+#LIB::StatisticalTest.quitR
+#t2 = Time.new
+#puts t2-t1
+