From c6e86fc1bfee7cb91782dd7067408d78a8e48ed9 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Tue, 8 Nov 2016 16:04:49 +0100 Subject: probability plot for classification --- test/descriptor.rb | 4 +++- test/validation-classification.rb | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/descriptor.rb b/test/descriptor.rb index e5d8ff9..42d4661 100644 --- a/test/descriptor.rb +++ b/test/descriptor.rb @@ -12,7 +12,9 @@ class DescriptorTest < MiniTest::Test def test_smarts c = OpenTox::Compound.from_smiles "N=C=C1CCC(=F=FO)C1" - File.open("tmp.png","w+"){|f| f.puts c.png} + File.open("/tmp/tmp.png","w+"){|f| f.puts c.png} + assert_match /^PNG/,`file -b /tmp/tmp.png` + File.delete "/tmp/tmp.png" s = Smarts.find_or_create_by(:smarts => "F=F") result = c.smarts_match [s] assert_equal [1], result diff --git a/test/validation-classification.rb b/test/validation-classification.rb index c93e71f..fb4c3e7 100644 --- a/test/validation-classification.rb +++ b/test/validation-classification.rb @@ -11,8 +11,10 @@ class ValidationClassificationTest < MiniTest::Test cv = ClassificationCrossValidation.create model assert cv.accuracy > 0.7, "Accuracy (#{cv.accuracy}) should be larger than 0.7, this may occur due to an unfavorable training/test set split" assert cv.weighted_accuracy > cv.accuracy, "Weighted accuracy (#{cv.weighted_accuracy}) should be larger than accuracy (#{cv.accuracy})." - #p cv - #File.open("tmp.pdf","w+"){|f| f.puts cv.probability_plot} + File.open("/tmp/tmp.pdf","w+"){|f| f.puts cv.probability_plot(format:"pdf")} + p `file -b /tmp/tmp.pdf` + File.open("/tmp/tmp.png","w+"){|f| f.puts cv.probability_plot(format:"png")} + p `file -b /tmp/tmp.png` end # parameters -- cgit v1.2.3