summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2016-10-12 21:44:29 +0200
committerChristoph Helma <helma@in-silico.ch>2016-10-12 21:44:29 +0200
commit1810b12e7faf2f0677482a3c7a8c23e0e11b8d29 (patch)
tree5e1c37397384fbc1b89623ce8f482767ff46bd0e
parentdc4ab1f4e64d738d6c0b70f0b690a2359685080f (diff)
R NAs fixed
-rw-r--r--lib/caret.rb3
-rw-r--r--lib/feature_selection.rb6
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