特征工具可以将特征列表直接保存到 s3



我正在尝试将从深度特征合成返回的特征列表直接保存到 S3。 如果在本地持久化,我可以使用"ft.save_features(功能,路径文件("。 无论如何都可以将 S3 网址传递给此方法吗?

现在,它只能写入本地磁盘。如果要保存到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)

最新更新