Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Featuretools Compatibility (#28)
- Loading branch information
Jeff Hernandez
committed
Jun 26, 2019
1 parent
e828e9c
commit a9cfe85
Showing
2 changed files
with
36 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import featuretools as ft | ||
import pytest | ||
|
||
from ..label_maker import LabelMaker | ||
|
||
|
||
def my_labeling_function(df_slice): | ||
label = df_slice['amount'].sum() | ||
return label | ||
|
||
|
||
@pytest.fixture | ||
def labels(): | ||
columns = ['transaction_time', 'customer_id', 'amount'] | ||
df = ft.demo.load_mock_customer(return_single_table=True, random_seed=0)[columns] | ||
lm = LabelMaker(target_entity='customer_id', time_index='transaction_time', labeling_function=my_labeling_function, window_size='1h') | ||
lt = lm.search(df, minimum_data='10min', num_examples_per_instance=2, gap='30min') | ||
lt = lt.threshold(1250) | ||
return lt | ||
|
||
|
||
def test_dfs(labels): | ||
es = ft.demo.load_mock_customer(return_entityset=True, random_seed=0) | ||
feature_matrix, _ = ft.dfs(entityset=es, target_entity='customers', cutoff_time=labels, cutoff_time_in_index=True) | ||
assert labels.name in feature_matrix | ||
|
||
columns = ['customer_id', 'time', labels.name] | ||
given_labels = feature_matrix.reset_index()[columns] | ||
given_labels = given_labels.rename(columns={'time': 'cutoff_time'}) | ||
given_labels = given_labels.sort_values(['customer_id', 'cutoff_time']) | ||
given_labels = given_labels.reset_index(drop=True) | ||
given_labels = given_labels.rename_axis('label_id') | ||
|
||
assert given_labels.equals(labels) |
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 |
---|---|---|
|
@@ -5,4 +5,5 @@ autopep8==1.4.3 | |
isort==4.3.4 | ||
jupyter==1.0.0 | ||
nbconvert==5.5.0 | ||
nbsphinx==0.4.2 | ||
nbsphinx==0.4.2 | ||
featuretools>=0.9.0 |