From 8a18ae8989eece6d3c6efd92ef298b9e8e7babe4 Mon Sep 17 00:00:00 2001 From: davor Date: Thu, 23 Feb 2012 17:14:00 +0100 Subject: Removing features with only NA values in rfe. --- lib/algorithm.rb | 8 ++++++++ 1 file changed, 8 insertions(+) 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 -- cgit v1.2.3