【问题标题】:FeatureTools GroupBy issue excluding entitiesFeatureTools GroupBy 问题不包括实体
【发布时间】:2020-03-02 01:32:54
【问题描述】:

这个问题是这个post的后续问题:

我可以解决第一部分的疑问,但之后又出现了另一个问题。

我有以下 Featuretools 实体集:

我想得到groupby_trans_primitivesDiffTimeSincePrevious(天),但只在录音实体中,不包括其他实体:'vendedores','produtos',cliente','produto_cliente'

我尝试了以下代码以不成功地排除这些实体:

from featuretools.primitives import TimeSincePrevious
time_since_previous = TimeSincePrevious(unit = "days")

fm, features = ft.dfs(entityset=es, 
                      target_entity='recordings',
                      trans_primitives = [],
                      agg_primitives = [],
                      max_depth=2,
                      verbose=True,
                      groupby_trans_primitives=['Diff',time_since_previous],
                      primitive_options={'time_since_previous': {'ignore_groupby_entities': ['vendedores','produtos','cliente']}})

因为代码返回了以下特性:

Built 38 features
Elapsed: 00:38 | Progress: 100%|██████████
[<Feature: CODIGO_CLIENTE>,
 <Feature: NOME_VENDEDOR>,
 <Feature: CODIGO_PRODUTO>,
 <Feature: QUANTIDADE>,
 <Feature: VALOR_TOTAL>,
 <Feature: PRODUTO_CLIENTE>,
 <Feature: DIFF(QUANTIDADE) by PRODUTO_CLIENTE>,
 <Feature: DIFF(QUANTIDADE) by CODIGO_PRODUTO>,
 <Feature: DIFF(QUANTIDADE) by NOME_VENDEDOR>,
 <Feature: DIFF(QUANTIDADE) by CODIGO_CLIENTE>,
 <Feature: DIFF(VALOR_TOTAL) by PRODUTO_CLIENTE>,
 <Feature: DIFF(VALOR_TOTAL) by CODIGO_PRODUTO>,
 <Feature: DIFF(VALOR_TOTAL) by NOME_VENDEDOR>,
 <Feature: DIFF(VALOR_TOTAL) by CODIGO_CLIENTE>,
 <Feature: TIME_SINCE_PREVIOUS(DATA_NOTA, unit=days) by PRODUTO_CLIENTE>,
 <Feature: TIME_SINCE_PREVIOUS(DATA_NOTA, unit=days) by CODIGO_PRODUTO>,
 <Feature: TIME_SINCE_PREVIOUS(DATA_NOTA, unit=days) by NOME_VENDEDOR>,
 <Feature: TIME_SINCE_PREVIOUS(DATA_NOTA, unit=days) by CODIGO_CLIENTE>,
 <Feature: cliente.CLASSIFICACAO>,
 <Feature: cliente.REDE>,
 <Feature: cliente.CIDADE>,
 <Feature: cliente.UF>,
 <Feature: TIME_SINCE_PREVIOUS(vendedores.first_recordings_time, unit=days) by PRODUTO_CLIENTE>,
 <Feature: TIME_SINCE_PREVIOUS(vendedores.first_recordings_time, unit=days) by CODIGO_PRODUTO>,
 <Feature: TIME_SINCE_PREVIOUS(vendedores.first_recordings_time, unit=days) by NOME_VENDEDOR>,
 <Feature: TIME_SINCE_PREVIOUS(vendedores.first_recordings_time, unit=days) by CODIGO_CLIENTE>,
 <Feature: TIME_SINCE_PREVIOUS(produto_cliente.first_recordings_time, unit=days) by PRODUTO_CLIENTE>,
 <Feature: TIME_SINCE_PREVIOUS(produto_cliente.first_recordings_time, unit=days) by CODIGO_PRODUTO>,
 <Feature: TIME_SINCE_PREVIOUS(produto_cliente.first_recordings_time, unit=days) by NOME_VENDEDOR>,
 <Feature: TIME_SINCE_PREVIOUS(produto_cliente.first_recordings_time, unit=days) by CODIGO_CLIENTE>,
 <Feature: TIME_SINCE_PREVIOUS(cliente.first_recordings_time, unit=days) by PRODUTO_CLIENTE>,
 <Feature: TIME_SINCE_PREVIOUS(cliente.first_recordings_time, unit=days) by CODIGO_PRODUTO>,
 <Feature: TIME_SINCE_PREVIOUS(cliente.first_recordings_time, unit=days) by NOME_VENDEDOR>,
 <Feature: TIME_SINCE_PREVIOUS(cliente.first_recordings_time, unit=days) by CODIGO_CLIENTE>,
 <Feature: TIME_SINCE_PREVIOUS(produtos.first_recordings_time, unit=days) by PRODUTO_CLIENTE>,
 <Feature: TIME_SINCE_PREVIOUS(produtos.first_recordings_time, unit=days) by CODIGO_PRODUTO>,
 <Feature: TIME_SINCE_PREVIOUS(produtos.first_recordings_time, unit=days) by NOME_VENDEDOR>,
 <Feature: TIME_SINCE_PREVIOUS(produtos.first_recordings_time, unit=days) by CODIGO_CLIENTE>]

而且我不知道为什么在我的代码中创建了以下功能以排除这些实体:

<Feature: TIME_SINCE_PREVIOUS(vendedores.first_recordings_time, unit=days) by PRODUTO_CLIENTE>,
 <Feature: TIME_SINCE_PREVIOUS(vendedores.first_recordings_time, unit=days) by CODIGO_PRODUTO>,
 <Feature: TIME_SINCE_PREVIOUS(vendedores.first_recordings_time, unit=days) by NOME_VENDEDOR>,
 <Feature: TIME_SINCE_PREVIOUS(vendedores.first_recordings_time, unit=days) by CODIGO_CLIENTE>,
 <Feature: TIME_SINCE_PREVIOUS(produto_cliente.first_recordings_time, unit=days) by PRODUTO_CLIENTE>,
 <Feature: TIME_SINCE_PREVIOUS(produto_cliente.first_recordings_time, unit=days) by CODIGO_PRODUTO>,
 <Feature: TIME_SINCE_PREVIOUS(produto_cliente.first_recordings_time, unit=days) by NOME_VENDEDOR>,
 <Feature: TIME_SINCE_PREVIOUS(produto_cliente.first_recordings_time, unit=days) by CODIGO_CLIENTE>,
 <Feature: TIME_SINCE_PREVIOUS(cliente.first_recordings_time, unit=days) by PRODUTO_CLIENTE>,
 <Feature: TIME_SINCE_PREVIOUS(cliente.first_recordings_time, unit=days) by CODIGO_PRODUTO>,
 <Feature: TIME_SINCE_PREVIOUS(cliente.first_recordings_time, unit=days) by NOME_VENDEDOR>,
 <Feature: TIME_SINCE_PREVIOUS(cliente.first_recordings_time, unit=days) by CODIGO_CLIENTE>,
 <Feature: TIME_SINCE_PREVIOUS(produtos.first_recordings_time, unit=days) by PRODUTO_CLIENTE>,
 <Feature: TIME_SINCE_PREVIOUS(produtos.first_recordings_time, unit=days) by CODIGO_PRODUTO>,
 <Feature: TIME_SINCE_PREVIOUS(produtos.first_recordings_time, unit=days) by NOME_VENDEDOR>,
 <Feature: TIME_SINCE_PREVIOUS(produtos.first_recordings_time, unit=days) by CODIGO_CLIENTE>]

我将不胜感激任何形式的帮助!谢谢!

【问题讨论】:

    标签: python-3.x jupyter-notebook feature-extraction featuretools


    【解决方案1】:

    primitive_options 忽略实体的方式实际上存在一个错误,这些实体将在下一版本的功能工具中得到修复,但现在您可以通过保留这些原始选项并添加 drop_contains 过滤器来过滤掉这些功能

    fm, features = ft.dfs(entityset=es, 
                          target_entity='recordings',
                          trans_primitives = [],
                          agg_primitives = [],
                          max_depth=2,
                          verbose=True,
                          groupby_trans_primitives=['Diff',time_since_previous],
                          drop_contains=["TIME_SINCE_PREVIOUS(produtos.", "TIME_SINCE_PREVIOUS(cliente.", "TIME_SINCE_PREVIOUS(produto_cliente.", "TIME_SINCE_PREVIOUS(vendedores."],
                          primitive_options={'time_since_previous': {'ignore_groupby_entities': ['vendedores','produtos','cliente']}})
    

    下一个版本发布后,我们将更新答案以在没有drop_contains 的情况下工作

    【讨论】:

    • 谢谢@Roy Wedge!期待下一个版本。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-28
    • 1970-01-01
    • 2011-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多