Created
October 27, 2012 16:31
-
-
Save bdewilde/3965255 to your computer and use it in GitHub Desktop.
how to remove features with near zero variance, not useful for discriminating classes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# helpful functions for classification/regression training | |
# http://cran.r-project.org/web/packages/caret/index.html | |
library(caret) | |
# get indices of data.frame columns (pixels) with low variance | |
badCols <- nearZeroVar(train) | |
print(paste("Fraction of nearZeroVar columns:", round(length(badCols)/length(train),4))) | |
# remove those "bad" columns from the training and cross-validation sets | |
train <- train[, -badCols] | |
cv <- cv[, -badCols] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment