From 1810b12e7faf2f0677482a3c7a8c23e0e11b8d29 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Wed, 12 Oct 2016 21:44:29 +0200 Subject: R NAs fixed --- lib/caret.rb | 3 +-- lib/feature_selection.rb | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/caret.rb b/lib/caret.rb index 59e02da..886e2f9 100644 --- a/lib/caret.rb +++ b/lib/caret.rb @@ -71,8 +71,7 @@ module OpenTox def self.to_r v return "F" if v == false return "T" if v == true - return "NA" if v.nil? - return "NA" if v.is_a? Float and v.nan? + return nil if v.is_a? Float and v.nan? v end diff --git a/lib/feature_selection.rb b/lib/feature_selection.rb index f599539..65f9752 100644 --- a/lib/feature_selection.rb +++ b/lib/feature_selection.rb @@ -10,7 +10,8 @@ module OpenTox selected_variables = [] selected_descriptor_ids = [] model.independent_variables.each_with_index do |v,i| - R.assign "independent", v.collect{|n| to_r(n)} + v.collect!{|n| to_r(n)} + R.assign "independent", v begin R.eval "cor <- cor.test(dependent,independent,method = 'pearson',use='pairwise')" pvalue = R.eval("cor$p.value").to_ruby @@ -20,7 +21,6 @@ module OpenTox selected_descriptor_ids << model.descriptor_ids[i] end rescue - #warn "Correlation of '#{model.prediction_feature.name}' (#{model.dependent_variables}) with '#{Feature.find(model.descriptor_ids[i]).name}' (#{v}) failed." warn "Correlation of '#{model.prediction_feature.name}' (#{model.dependent_variables}) with (#{v}) failed." end end @@ -33,8 +33,6 @@ module OpenTox def self.to_r v return 0 if v == false return 1 if v == true - return "NA" if v.nil? - return "NA" if v.is_a? Float and v.nan? v end -- cgit v1.2.3