Source code for featuretools.selection.selection
[docs]def remove_low_information_features(feature_matrix, features=None):
"""Select features that have at least 2 unique values and that are not all null
Args:
feature_matrix (:class:`pd.DataFrame`): DataFrame whose columns are feature names and rows are instances
features (list[:class:`featuretools.FeatureBase`] or list[str], optional): List of features to select
Returns:
(feature_matrix, features)
"""
keep = [c for c in feature_matrix
if (feature_matrix[c].nunique(dropna=False) > 1 and
feature_matrix[c].dropna().shape[0] > 0)]
feature_matrix = feature_matrix[keep]
if features is not None:
features = [f for f in features
if f.get_name() in feature_matrix.columns]
return feature_matrix, features
return feature_matrix