summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavor <vorgrimmlerdavid@gmx.de>2012-02-23 17:14:00 +0100
committerdavor <vorgrimmlerdavid@gmx.de>2012-02-23 17:14:00 +0100
commit8a18ae8989eece6d3c6efd92ef298b9e8e7babe4 (patch)
tree43fd638a05e9b5a459eda40e0e8c308958eb3131
parent44780f8305e3a4fbaa0c06ce73af50e95105a813 (diff)
Removing features with only NA values in rfe.
-rw-r--r--lib/algorithm.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/algorithm.rb b/lib/algorithm.rb
index db21c46..fb14482 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