amazon-s3 - 功能工具可以将功能列表直接保存到s3吗?
问题描述
我正在尝试将从深度特征合成返回的特征列表直接保存到 S3。如果在本地持久化,我可以使用“ft.save_features(features,pathtofile)”。反正有没有将 S3 url 传递给这个方法?
解决方案
目前,它只能写入本地磁盘。如果要保存到 S3 并稍后从 S3 下载,可以通过像这样将文件写入磁盘和从磁盘写入文件来实现
import featuretools as ft
import boto
es = ft.demo.load_mock_customer(return_entityset=True)
feature_defs = ft.dfs(entityset=es,
target_entity="customers",
agg_primitives=["count"],
trans_primitives=["month"],
max_depth=1,
features_only=True)
# save features to disk
saved_features_file = "feature_defs"
ft.save_features(feature_defs, saved_features_file)
# upload to s3
s3_connection = boto.connect_s3()
bucket = s3_connection.get_bucket('featuretools-static')
key = boto.s3.key.Key(bucket, saved_features_file)
key.set_contents_from_filename(saved_features_file)
# download from s3
downloaded_features_file = "feature_defs_downloaded"
key.get_contents_to_filename(downloaded_features_file)
feature_defs_s3 = ft.load_features(downloaded_features_file)
# test to make sure it works
feature_matrix = ft.calculate_feature_matrix(entityset=es, features=feature_defs_s3)
推荐阅读
- github - 更改 github wiki 页面路径
- python-3.x - PySpark 将列拆分为具有应用架构的新数据框
- twig - 如何将一个块移动到另一个块
- python - 为什么重新加载是在 django 中提交表单?
- java - 如何在 Apache POI 5.1.0 中使用数组溢出
- arrays - 如何绕过零大小的数组?
- azure-devops - 如何在 Azure DevOps 管道中根据需要设置 SonarQube 代码检查
- bash - 如何剪切 Bash 变量中的特定字符(无需任何额外命令)
- amazon-web-services - 堆栈漂移时更新 Cloudformation 中的 DeletionPolicy
- nginx - 将 nginx 入口从部署更新到 daemonset