我正试图保留从深度特征合成直接返回到S3的特征列表。如果在本地保留,则可以使用“ ft.save_features(features,pathtofile)”。反正有将S3网址传递给此方法吗?
答案 0 :(得分:0)
现在,它只能写入本地磁盘。如果要保存到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)