From 9400b9abba43cc3a9d2a21d1ab174534de9f9128 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Thu, 16 Dec 2010 17:30:08 +0100 Subject: lazar results rounded to 4 decimal points --- Rakefile | 1 + algorithm.rb | 16 ---------------- fminer.rb | 2 +- lazar.rb | 12 +++++++++--- 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/Rakefile b/Rakefile index 01050c8..a287f95 100644 --- a/Rakefile +++ b/Rakefile @@ -5,6 +5,7 @@ TEST_USER = "guest" TEST_PW = "guest" task ARGV[0] do + puts ENV["RACK_ENV"] puts ARGV[0]+".rb" require "./"+ARGV[0]+".rb" end diff --git a/algorithm.rb b/algorithm.rb index a5f35d1..055f0a2 100644 --- a/algorithm.rb +++ b/algorithm.rb @@ -24,21 +24,5 @@ class AlgorithmTest < Test::Unit::TestCase end end -=begin - def test_run_external - { - #"http://opentox.informatik.tu-muenchen.de:8080/OpenTox-dev/algorithm/J48" => {:dataset_uri => "http://apps.ideaconsult.net:8080/ambit2/dataset/10", :prediction_feature => "http://apps.ideaconsult.net:8080/ambit2/feature/21595"}, - #"http://apps.ideaconsult.net:8080/ambit2/algorithm/toxtreeskinirritation" => {:dataset_uri => "http://apps.ideaconsult.net:8080/ambit2/dataset/2698" }, # TASK redirects to model - "http://opentox.informatik.tu-muenchen.de:8080/OpenTox-dev/algorithm/CDKPhysChem" => {:dataset_uri => "http://apps.ideaconsult.net:8080/ambit2/dataset/2698" }, - #"http://apps.ideaconsult.net:8080/ambit2/algorithm/org.openscience.cdk.qsar.descriptors.molecular.ALOGPDescriptor" => {:dataset_uri => "http://apps.ideaconsult.net:8080/ambit2/dataset/2698" } - #"http://opentox.ntua.gr:3000/algorithm/svm" - }.each do |uri,params| - algorithm = OpenTox::Algorithm::Generic.new uri - dataset_uri = algorithm.run(params) - dataset = OpenTox::Dataset.find dataset_uri - puts dataset.to_yaml - end - end -=end end diff --git a/fminer.rb b/fminer.rb index c52f78c..a8552d7 100644 --- a/fminer.rb +++ b/fminer.rb @@ -22,7 +22,7 @@ class FminerTest < Test::Unit::TestCase dataset_uri = OpenTox::Algorithm::Fminer::LAST.new.run({:dataset_uri => @@classification_training_dataset.uri, :prediction_feature => feature, :subjectid => @@subjectid}).to_s d =OpenTox::Dataset.new dataset_uri d.load_features - assert_equal 35, d.features.size + assert_equal 36, d.features.size #validate_owl d.delete(@@subjectid) end diff --git a/lazar.rb b/lazar.rb index 6324f3c..0ee7a43 100644 --- a/lazar.rb +++ b/lazar.rb @@ -2,6 +2,12 @@ require 'rubygems' require 'opentox-ruby' require 'test/unit' +class Float + def round_to(x) + (self * 10**x).round.to_f / 10**x + end +end + class LazarTest < Test::Unit::TestCase =begin @@ -13,8 +19,8 @@ class LazarTest < Test::Unit::TestCase compound = OpenTox::Compound.from_smiles("c1ccccc1NN") prediction_uri = lazar.run(:compound_uri => compound.uri, :subjectid => @@subjectid) prediction = OpenTox::LazarPrediction.find(prediction_uri) - assert_equal prediction.value(compound), 0.149480050002539 - assert_equal prediction.confidence(compound), 0.615246530364447 + assert_equal prediction.value(compound).round_to(4), 0.149518871336721.round_to(4) + assert_equal prediction.confidence(compound).round_to(4), 0.615246530364447.round_to(4) assert_equal prediction.neighbors(compound).size, 81 prediction.delete(@@subjectid) lazar.delete(@@subjectid) @@ -30,7 +36,7 @@ class LazarTest < Test::Unit::TestCase prediction_uri = lazar.run(:compound_uri => compound.uri, :subjectid => @@subjectid) prediction = OpenTox::LazarPrediction.find(prediction_uri) assert_equal prediction.value(compound), false - assert_equal prediction.confidence(compound), 0.25857114104619 + assert_equal prediction.confidence(compound).round_to(4), 0.25857114104619.round_to(4) assert_equal prediction.neighbors(compound).size, 15 prediction.delete(@@subjectid) # dataset activity -- cgit v1.2.3