Search code examples
featuretools

How to select features from feature_def created through deep feature synthesis


I am using deep feature synthesis to create new features. How can I select features from feature_def.

For example, I need to select all the features with string "Age" in it. I tried the following code which gave me an error "argument of type 'IdentityFeature' is not iterable"

    feature_matrix, feature_defs = ft.dfs(entityset= es, target_entity= 'titanic', max_depth= 2)
    features = []
    for s in feature_defs:
      if 'Age' in s:
        features.append(s)

Solution

  • You need to use the .get_name() method on the feature definition. For example,

    feature_matrix, feature_defs = ft.dfs(entityset= es, target_entity= 'titanic', max_depth= 2)
    features = []
    for s in feature_defs:
      if 'Age' in s.get_name():
        features.append(s)