我正在尝试将从深度特征合成返回的特征列表直接持久化到S3。如果在本地持久化,我可以使用"ft.save_features(features,pathtofile)“。有没有办法把一个S3 url传递给这个方法?
发布于 2019-04-03 11:20:45
现在,它只能写入本地磁盘。如果您想要保存到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)
https://stackoverflow.com/questions/55482233
复制相似问题