Skip to content

Instantly share code, notes, and snippets.

@calippo
Created October 12, 2015 08:33
Show Gist options
  • Save calippo/9f726ef197b36d6e9f39 to your computer and use it in GitHub Desktop.
Save calippo/9f726ef197b36d6e9f39 to your computer and use it in GitHub Desktop.
[pandas, scikit-learn] Feature selection using low variance
def varianceSelection(X, THRESHOLD = .95):
sel = VarianceThreshold(threshold=(THRESHOLD * (1 - THRESHOLD)))
sel.fit_transform(X)
return X[[c for (s, c) in zip(sel.get_support(), X.columns.values) if s]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment