Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Datetime Feature +/- pd.Timedelta #629

Open
wujunzhuo opened this issue Jun 28, 2019 · 4 comments
Open

Support Datetime Feature +/- pd.Timedelta #629

wujunzhuo opened this issue Jun 28, 2019 · 4 comments

Comments

@wujunzhuo
Copy link

@wujunzhuo wujunzhuo commented Jun 28, 2019

Bug/Feature Request Description

In [1]: import featuretools as ft                                                                                                                             

In [2]: es = ft.demo.load_mock_customer(return_entityset=True)                                                                                                

In [3]: import pandas as pd                                                                                                                                   

In [4]: f = ft.Feature(es['customers']['date_of_birth'])                                                                                                      

In [5]: ft.calculate_feature_matrix([f + pd.Timedelta(1, 'y')], es)                                                                                           
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-5-340973cfbfbd> in <module>
----> 1 ft.calculate_feature_matrix([f + pd.Timedelta(1, 'y')], es)

/usr/local/lib/python3.7/site-packages/featuretools/feature_base/feature_base.py in __add__(self, other)
    242     def __add__(self, other):
    243         """Add other"""
--> 244         return self._handle_binary_comparision(other, primitives.AddNumeric, primitives.AddNumericScalar)
    245 
    246     def __radd__(self, other):

/usr/local/lib/python3.7/site-packages/featuretools/feature_base/feature_base.py in _handle_binary_comparision(self, other, Primitive, PrimitiveScalar)
    214             return Feature([self, other], primitive=Primitive)
    215 
--> 216         return Feature([self], primitive=PrimitiveScalar(other))
    217 
    218     def __eq__(self, other):

/usr/local/lib/python3.7/site-packages/featuretools/feature_base/feature_base.py in __new__(self, base, entity, groupby, parent_entity, primitive, use_previous, where)
    733                                                primitive=primitive,
    734                                                groupby=groupby)
--> 735             return TransformFeature(base, primitive=primitive)
    736 
    737         raise Exception("Unrecognized feature initialization")

/usr/local/lib/python3.7/site-packages/featuretools/feature_base/feature_base.py in __init__(self, base_features, primitive, name)
    637                                                relationship_path=RelationshipPath([]),
    638                                                primitive=primitive,
--> 639                                                name=name)
    640 
    641     @classmethod

/usr/local/lib/python3.7/site-packages/featuretools/feature_base/feature_base.py in __init__(self, entity, base_features, relationship_path, primitive, name)
     53         self._name = name
     54 
---> 55         assert self._check_input_types(), ("Provided inputs don't match input "
     56                                            "type requirements")
     57 

AssertionError: Provided inputs don't match input type requirements
@kmax12
Copy link
Contributor

@kmax12 kmax12 commented Jun 28, 2019

hi @wujunzhuo - thanks for the suggestion!

We can look into supporting this. Can you explain the use case for doing this while performing feature engineering?

@wujunzhuo
Copy link
Author

@wujunzhuo wujunzhuo commented Jul 1, 2019

hi @wujunzhuo - thanks for the suggestion!

We can look into supporting this. Can you explain the use case for doing this while performing feature engineering?

Thanks for your reply.

We're aiming to build a number of features in different time periods, like Average Income In Recent 1/5/10 Years, 1/3/7-day Login Times After First Registration, etc.

First We tried the use_previous mechanism. However, features are not based on a single cutoff_time; therefore we might need to call the calculate_feature_matrix many times. Instead we put these time durations as feature where conditions, and without the add/subtract operands support, we simply convert the Datetime type to Numeric(unix timestamp).

😊

@kmax12
Copy link
Contributor

@kmax12 kmax12 commented Jul 1, 2019

@wujunzhuo does that mean you would also need the date time features to work with the <, <=, >, and >= operators?

if possible, can you share a example snippet of code you're using to do this to confirm we understand what you're requesting

@rwedge
Copy link
Collaborator

@rwedge rwedge commented May 21, 2020

This could probably be achieved by updating AddNumericScalar and similar primitives to support Numeric or Datetime inputs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.