summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Maunz <andreas@maunz.de>2012-02-24 11:05:12 +0100
committerAndreas Maunz <andreas@maunz.de>2012-02-24 11:05:12 +0100
commit8a4460be1f378c577d381ff119f6dc9090671a5c (patch)
tree3e730e99fd2685a28e2ce9d7eb790378eff559f5
parentd7c0289a438f26c4fadd4468623f3152119e7f5a (diff)
parent8a18ae8989eece6d3c6efd92ef298b9e8e7babe4 (diff)
Merge branch 'jl' of github.com:opentox/opentox-ruby into jl
-rw-r--r--lib/algorithm.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/algorithm.rb b/lib/algorithm.rb
index bf058fd..f57954d 100644
--- a/lib/algorithm.rb
+++ b/lib/algorithm.rb
@@ -476,6 +476,14 @@ module OpenTox
# assumes a data matrix 'features' and a vector 'y' of target values
row.names(features)=NULL
+ # features with all values missing removed
+ na_col = names ( which ( apply ( features, 2, function(x) all ( is.na ( x ) ) ) ) )
+ features = features[,!names(features) %in% na_col]
+
+ # features with zero variance removed
+ zero_var = names ( which ( apply ( features, 2, function(x) var(x, na.rm=T) ) == 0 ) )
+ features = features[,!names(features) %in% zero_var]
+
pp = NULL
if (del_missing) {
# needed if rows should be removed