2

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

4

1 回答 1

4

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

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()
于 2019-03-14T21:16:15.553 回答