【问题标题】:How to use Featuretools to create features for a single table with no immediate features?如何使用 Featuretools 为没有直接特征的单个表创建特征?
【发布时间】:2019-08-04 22:13:20
【问题描述】:

我使用了@willk 的答案,但它弹出一个错误。 在这里查看威尔克的答案。 willk's anser 我无法在他的回答中发表评论,因为我没有足够的声誉(超过 50 岁)。

所以我的问题是如何使下面的代码工作?或者请提供一个解决方案,使用功能工具为单个表应用自动特征工程(以 iris 为例),并且没有立即规范化的特征(从现有表创建一个新表)。

from sklearn.datasets import load_iris
import pandas as pd 
import featuretools as ft

# Load data and put into dataframe
iris = load_iris()
df = pd.DataFrame(iris.data, columns = iris.feature_names)
df['species'] = iris.target
df['species'] = df['species'].map({0: 'setosa', 1: 'versicolor', 2: 'virginica'})

# Make an entityset and add the entity
es = ft.EntitySet(id = 'iris')
es.entity_from_dataframe(entity_id = 'data', dataframe = df, 
                     make_index = True, index = 'index')

# Run deep feature synthesis with transformation primitives
feature_matrix, feature_defs = ft.dfs(entityset = es, target_entity = 'data',
                                  trans_primitives = ['add', 'multiply'])
feature_matrix.head()

ValueError: ('Unknown transform primitive add.', 'Call ft.primitives.list_primitives() to get', 'a list of available primitives')

【问题讨论】:

    标签: python featuretools


    【解决方案1】:

    功能工具的 0.6.1 版本更改了一些原始名称。以下代码应该会为您运行

    from sklearn.datasets import load_iris
    import pandas as pd 
    import featuretools as ft
    
    # Load data and put into dataframe
    iris = load_iris()
    df = pd.DataFrame(iris.data, columns = iris.feature_names)
    df['species'] = iris.target
    df['species'] = df['species'].map({0: 'setosa', 1: 'versicolor', 2: 'virginica'})
    
    # Make an entityset and add the entity
    es = ft.EntitySet(id = 'iris')
    es.entity_from_dataframe(entity_id = 'data', dataframe = df, 
                         make_index = True, 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'])
    feature_matrix.head()
    

    【讨论】:

      猜你喜欢
      • 2018-10-17
      • 2019-05-03
      • 2021-10-03
      • 2020-08-09
      • 2021-07-25
      • 1970-01-01
      • 1970-01-01
      • 2022-06-14
      • 2020-07-29
      相关资源
      最近更新 更多