Skip to content

Instantly share code, notes, and snippets.

@Ayushijain09
Last active July 13, 2020 19:00
Show Gist options
  • Save Ayushijain09/c9b1acf5a6a3b17261969f93df90b65a to your computer and use it in GitHub Desktop.
Save Ayushijain09/c9b1acf5a6a3b17261969f93df90b65a to your computer and use it in GitHub Desktop.
from sklearn.feature_selection import VarianceThreshold
print(df_train.shape) #output (143, 59)
var_filter = VarianceThreshold(threshold = 0.0)
train = var_filter.fit_transform(df_train)
#to get the count of features that are not constant
print(train.shape()) # output (143, 56)
#or
print(len(df_train.columns[var_filter.get_support()])) #output 56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment