I have a dataframe of features and I'd like to remove low variance features. I used the following function to filter out low variance columns:
def variance_threshold_selector(data, threshold):
selector = VarianceThreshold(threshold)
selector.fit(data)
return data[data.columns[selector.get_support(indices=True)]]
And I got the following warning for different threshold values:
/anaconda3/envs/Observation/lib/python3.7/site-packages/sklearn/feature_selection/_variance_threshold.py:77: RuntimeWarning: Degrees of freedom <= 0 for slice.
self.variances_ = np.nanvar(X, axis=0)
/anaconda3/envs/Observation/lib/python3.7/site-packages/sklearn/feature_selection/_variance_threshold.py:88: RuntimeWarning: invalid value encountered in less_equal
(self.variances_ <= self.threshold)):
/anaconda3/envs/Observation/lib/python3.7/site-packages/sklearn/feature_selection/_variance_threshold.py:99: RuntimeWarning: invalid value encountered in greater
What are these warnings and how can I resolve them?