仅在特定列上使用 FeatureTools

Use FeatureTools on specific columns only

我正在尝试使用特征工具为泰坦尼克号数据集仅使用一些指定的列来生成一些新特征。在我的例子中,我想对 Age、Pclass 和 log10splitfare 进行转换 'add_numeric' 和 'multiply_numeric'。我遵循了 here to the best of my knowledge but no avail. The code below does not error out but it does not produce any additional columns. I also used this Whosebug 给出的语法作为参考。

es = ft.EntitySet(id = 'Titanic')
es.entity_from_dataframe(entity_id = 'data', dataframe = ftdataset_cleaned, 
                         make_index = False, index = 'index')

# Run deep feature synthesis with transformation primitives
feature_matrix, feature_defs = ft.dfs(entityset = es, target_entity = 'data',
                                      trans_primitives = ['add_numeric', 'multiply_numeric'],
                                      primitive_options= {('add_numeric', 'multiply_numeric'):{"include_entities": ['Age','PClass','log10SplitFare']}}
                                      )

您可以使用 include_variables 选项指定实体中的哪些列用于特定基元

feature_matrix, feature_defs = ft.dfs(
    entityset=es,
    target_entity='data',
    trans_primitives=['add_numeric', 'multiply_numeric'],
    primitive_options={
        ('add_numeric', 'multiply_numeric'): {
            'include_variables': {'data': ['Age', 'PClass', 'log10SplitFare']}}})

This guide 更深入地介绍了可以控制基元应用方式的不同方式。