How to decide what threshold to use for removing low-variance features?
Particularly, I have 100000 features and the variances look like:
Could I e.g. take the average and use it to split this to ~half?
Or some other method of grouping?
Data Science Stack Exchange is a question and answer site for Data science professionals, Machine Learning specialists, and those interested in learning more about the field. It only takes a minute to sign up.
Sign up to join this communityHow to decide what threshold to use for removing low-variance features?
Particularly, I have 100000 features and the variances look like:
Could I e.g. take the average and use it to split this to ~half?
Or some other method of grouping?
You can do this a few ways, which I can list in ascending order of effort:
Pick a value that seems ok for you and your dataset by eye-balling it then simply cut variables below the theshold from the dataset
Create a function, which given a threshold, tells you how many variables would be removed, if you used that threshold. Then create a simple plot and see if there is a certain level that seems appealing (this depends on your target model once data is ready).
Use some smarter functions that d a little more for you, e.g. the NearZeroVar function in the Caret package in R
There are, however, some arguments as to whether these approaches in general are optimal. Have a look at some of the discussion on this thread over at Cross-Validated. The quote from the OP in that thread if from the book of the guy who wrote the above mentioned Caret package - Max Kuhn.
The arguments against this approach say that you may be moving variables that, although they have low variance, might actually be extremely powerful in explaining your target (dependent) variable.
A final approach I can suggest goes into the realm of covariance, that is to look at the collinearity between pairs of variables. I have done this in the past and it worked out well for me. The basic algorithm would look something like this:
Here is the Scikit-Learn class which can do basic variance thresholding for you - there is also a short tutorial. They also present some ways to do recursive feature selection, similar in nature to my final approach outlined above.