该featuretools在其第一句话文档状态:
“ Featuretools是执行自动化特征工程的框架。它擅长将时间和关系数据集转换为用于机器学习的特征矩阵。”
这似乎暗示数据集必须具有datetime列。我只想让它确认实际上是这样。也就是说,例如,我不能在“ iris”数据集上使用它来生成新功能吗?如果数据集不需要时间变量,我将如何使用它在“ iris”数据集上生成要素。我将不胜感激。谢谢。
处理完毕后,我的数据是一个表,其中有几列是要素,一列是标签.我想用它featuretools.dfs来帮我预测标签.可以直接进行,还是需要将单个表分成多个?
我尝试按照 featuretools.com 的文档来学习 featuretools。
出现错误:AttributeError:“EntitySet”对象没有属性“entity_from_dataframe”
你可以帮帮我吗?谢谢。
代码:
import featuretools as ft
data = ft.demo.load_mock_customer()
transactions_df = data["transactions"].merge(data["sessions"]).merge(data["customers"])
transactions_df.sample(10)
products_df = data["products"]
products_df
es = ft.EntitySet(id="customer_data")
es = es.entity_from_dataframe(entity_id="transactions",
dataframe=transactions_df,
index="transaction_id",
time_index="transaction_time",
variable_types={"product_id": ft.variable_types.Categorical,
"zip_code": ft.variable_types.ZIPCode})
es
Run Code Online (Sandbox Code Playgroud)
我已经构建了一个实体集,并且该实体集中的其中一个表称为“检查”。我已经为这个表设置了 time_index 列,但是在运行 dfs 时,我收到警告“使用 training_window 但 last_time_index 未在实体检查中设置”。文档显示这应该设置为一个系列: last_time_index (pd.Series) – 所有子实体中每个实例的最后一个事件的时间索引。
有人可以提供一个示例,说明我应该如何将 last_time_index 设置为哪些值?
请注意,计算仍然正确,但我担心警告消息。
我有一个数据框,想使用 featuretools 进行自动特征工程部分。我可以使用规范化实体功能来做到这一点。代码片段如下:
es = ft.EntitySet(id = 'obs_data')
es = es.entity_from_dataframe(entity_id = 'obs', dataframe = X_train,
variable_types = variable_types, make_index = True, index = "Id")
for feat in interaction: # interaction columns are found using xgbfir
es = es.normalize_entity(base_entity_id='obs', new_entity_id=feat, index=feat)
features, feature_names = ft.dfs(entityset = es,
target_entity = 'obs',
max_depth = 2)
Run Code Online (Sandbox Code Playgroud)
它的创建功能,现在我想为 X_test 做同样的事情。我阅读了有关此的博客,他们建议将 X_train 和 X_test 结合起来,然后执行相同的过程。假设 X_test 中有 5 个 obs,如果我将它与 X_train 结合起来,那么每个观察(来自 X_test)也会对其他 4 个观察(X_test)产生影响,这不是一个好主意。任何人都可以建议如何使用新数据的特征工具进行特征工程?
在将数据帧作为实体集中的实体传递并在其上使用 DFS 时,我们是否应该从 DFS 中排除目标变量?在手动尝试传统特征选择方法并使用特征工具查看它是否提高了分数后,我有一个模型的 roc_auc 分数为 0.76。所以在包含目标变量的实体集上使用了 DFS。令人惊讶的是,roc_auc 分数上升到 0.996,准确度上升到 0.9997,所以我对分数表示怀疑,因为我将目标变量也传递到深度特征合成中,并且与目标相关的信息可能已泄露到训练中?我假设正确吗?
Featuretools 支持已经处理多个截止时间https://docs.featuretools.com/automated_feature_engineering/handling_time.html
In [20]: temporal_cutoffs = ft.make_temporal_cutoffs(cutoffs['customer_id'],
....: cutoffs['cutoff_time'],
....: window_size='3d',
....: num_windows=2)
....:
In [21]: temporal_cutoffs
Out[21]:
time instance_id
0 2011-12-12 13458
1 2011-12-15 13458
2 2012-10-02 13602
3 2012-10-05 13602
4 2012-01-22 15222
5 2012-01-25 15222
In [22]: entityset = ft.demo.load_retail()
In [23]: feature_tensor, feature_defs = ft.dfs(entityset=entityset,
....: target_entity='customers',
....: cutoff_time=temporal_cutoffs,
....: cutoff_time_in_index=True,
....: max_features=4)
....:
In [24]: feature_tensor
Out[24]:
MAX(order_products.total) MIN(order_products.unit_price) STD(order_products.quantity) COUNT(order_products)
customer_id time
13458.0 2011-12-12 201.960 0.3135 10.053804 394
2011-12-15 201.960 0.3135 10.053804 394 …Run Code Online (Sandbox Code Playgroud) python feature-extraction pandas feature-engineering featuretools
我目前正在使用自己的数据处理功能工具演示(https://github.com/Featuretools/predict_next_purchase/blob/master/Tutorial.ipynb).我创建了一个实体集,并尝试首先创建标签.笔记本引用了import utils,但没有使用功能工具进行安装.这是我需要安装的独立模块吗?
python 2.7 pip install featuretools
我正在尝试根据之前的结果来预测足球比赛的结果。我在 Windows 上运行 Python 3.6 并使用 Featuretools 0.4.1。
假设我有以下代表结果历史记录的数据框。
使用上面的数据框,我想创建以下数据框,它将作为X馈送到机器学习算法。请注意,无论过去的比赛场地如何,主队和客队的平均进球数都需要按球队计算。有没有办法使用Featuretools创建这样的数据框?
我正在尝试使用特征工具仅使用泰坦尼克号数据集的一些指定列来生成一些新特征。就我而言,我想对 Age、Pclass 和 log10splitfare 进行转换“add_numeric”和“multiply_numeric”。据我所知,我遵循了此处给出的语法,但无济于事。下面的代码不会出错,但不会产生任何额外的列。我也使用这个 stackoverflow链接 作为参考。
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']}}
)
Run Code Online (Sandbox Code Playgroud)