-
Notifications
You must be signed in to change notification settings - Fork 879
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* bump to v0.1.11
- Loading branch information
Showing
9 changed files
with
88 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,4 @@ | |
from .utils.pickle_utils import * | ||
import featuretools.demo | ||
|
||
__version__ = '0.1.10' | ||
__version__ = '0.1.11' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# flake8: noqa | ||
from .variance_selection import * | ||
from .selection import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
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.PrimitiveBase`] or list[str], optional): | ||
List of features to select | ||
''' | ||
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 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from featuretools.selection import remove_low_information_features | ||
from featuretools.tests.testing_utils import make_ecommerce_entityset | ||
from featuretools import Feature | ||
import numpy as np | ||
import pandas as pd | ||
import pytest | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def feature_matrix(): | ||
feature_matrix = pd.DataFrame({'test': [0, 1, 2], | ||
'no_null': [np.nan, 0, 0], | ||
'some_null': [np.nan, 0, 0], | ||
'all_null': [np.nan, np.nan, np.nan], | ||
'many_value': [1, 2, 3], | ||
'dup_value': [1, 1, 2], | ||
'one_value': [1, 1, 1]}) | ||
return feature_matrix | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def es(feature_matrix): | ||
es = make_ecommerce_entityset() | ||
es.entity_from_dataframe('test', feature_matrix, index='test') | ||
return es | ||
|
||
|
||
def test_remove_low_information_feature_names(feature_matrix): | ||
feature_matrix = remove_low_information_features(feature_matrix) | ||
assert feature_matrix.shape == (3, 5) | ||
assert 'one_value' not in feature_matrix.columns | ||
assert 'all_null' not in feature_matrix.columns | ||
|
||
|
||
def test_remove_low_information_features(es, feature_matrix): | ||
features = [Feature(v) for v in es['test'].variables] | ||
feature_matrix, features = remove_low_information_features(feature_matrix, | ||
features) | ||
assert feature_matrix.shape == (3, 5) | ||
assert len(features) == 5 | ||
for f in features: | ||
assert f.get_name() in feature_matrix.columns | ||
assert 'one_value' not in feature_matrix.columns | ||
assert 'all_null' not in feature_matrix.columns |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters