0

When using the time_since_last primitive, how do I change the units from seconds (the default) to days?

I see in the documentation TimeSinceLast objec accepts a units param, but I can’t see an easy way to pass it when using dfs or calculate_feature_matrix.

Max Kanter
  • 2,006
  • 6
  • 16

1 Answers1

1

In order to do this, you have to import the primitive in a slightly different way. Instead of using the shortcut way to choose a primitive with a list of strings, you have to import the primitive object and pass that into the dfs or calculate_feature_matrix function:

#Shortcut method

feature_matrix, feature_defs = ft.dfs(
          entityset=es,
          target_entity="customers",
          agg_primitives=["time_since_last", "std", "skew"],
          trans_primitives=[]) 


#method that allows initialization of variables

from featuretools.primitives import TimeSinceLast
time_since_last = TimeSinceLast(unit = "hours")
feature_matrix, feature_defs = ft.dfs(
          entityset=es,
          target_entity="customers",
          agg_primitives=[time_since_last, "std", "skew"],
          trans_primitives=[])

The key points are:

  1. import the specific feature you want to customize/change the behavior of
  2. define the feature, and put that definition in the list of primitives you are including (can be listed along with other strings).
Max Kanter
  • 2,006
  • 6
  • 16