使用neptune-export工具或 Neptune 导出服务,用于从 Neptune 中导出数据,用于 Neptune ML - Amazon Neptune
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

使用neptune-export工具或 Neptune 导出服务,用于从 Neptune 中导出数据,用于 Neptune ML

Neptune ML 要求您提供训练数据深图库 (DGL)以创建和评估模型。

您可以使用以下任一方法从 Neptune 导出数据海王星出口服务,或者neptune-export实用程序. 此项服务和命令行工具均以 CSV 格式将数据发布到 Amazon Simple Storage Service (Amazon S3),并使用 Amazon S3 服务器端加密进行加密(SSE-S3)。请参阅由 Neptune-Export 导出的文件neptune-export

此外,当您为 Neptune ML 配置训练数据导出时,导出作业会创建并发布加密的模型训练配置文件以及导出的数据。默认情况下,此文件名为training-data-configuration.json.

使用 Neptune-Export 服务导出 Neptune ML 的训练数据的示例

此请求导出节点分类任务的属性图训练数据:

curl \ (your NeptuneExportApiUri) \ -X POST \ -H 'Content-Type: application/json' \ -d '{ "command": "export-pg", "outputS3Path": "s3://(your Amazon S3 bucket)/neptune-export", "params": { "endpoint": "(your Neptune endpoint DNS name)", "profile": "neptune_ml" }, "additionalParams": { "neptune_ml": { "version": "v2.0", "targets": [ { "node": "Movie", "property": "genre", "type": "classification" } ] } } }'

此请求导出节点分类任务的 RDF 训练数据:

curl \ (your NeptuneExportApiUri) \ -X POST \ -H 'Content-Type: application/json' \ -d '{ "command": "export-rdf", "outputS3Path": "s3://(your Amazon S3 bucket)/neptune-export", "params": { "endpoint": "(your Neptune endpoint DNS name)", "profile": "neptune_ml" }, "additionalParams": { "neptune_ml": { "version": "v2.0", "targets": [ { "node": "http://aws.amazon.com/neptune/csv2rdf/class/Movie", "predicate": "http://aws.amazon.com/neptune/csv2rdf/datatypeProperty/genre", "type": "classification" } ] } } }'

要在中设置的字段params导出训练数据时的对象

这些区域有:params导出请求中的对象可以包含各种字段,如params文档. 以下几个与导出机器学习训练数据最相关:

  • endpoint— 使用endpoint以指定数据库集群中的 Neptune 实例的终端节点,导出过程可以查询该终端节点以提取数据。

  • profile— 该profile字段中的params对象必须设置为neptune-ml.

    这会导致导出过程为 Neptune ML 模型训练而适当地格式化导出的数据,格式为属性图数据的 CSV 格式,或者作为 RDF 数据的 N-Triples 格式。它还会导致training-data-configuration.json文件将创建并写入与导出的培训数据相同的 Amazon S3 位置。

  • cloneCluster— 如果设置为true,导出过程将克隆数据库集群,从克隆中导出,然后在克隆完成后将其删除。

  • useIamAuth— 如果您的数据库集群有IAM 身份验证启用,则必须将此字段设置为true.

导出过程还提供了几种筛选导出数据的方法(请参阅这些示例)。

使用additionalParams对象来调整模型训练信息的导出

这些区域有:additionalParams对象包含的字段可用于指定机器学习类标签和训练功能,并指导创建训练数据配置文件。

导出过程无法自动推断哪些节点和边缘属性应该是机器学习类标签,以便作为培训目的的示例。它也无法自动推断数字、分类和文本属性的最佳要素编码,因此您需要使用additionalParams对象来指定这些内容,或者覆盖默认编码。

对于属性图表数据,additionalParams在导出请求中可能类似于下面这样:

{ "command": "export-pg", "outputS3Path": "s3://(your Amazon S3 bucket)/neptune-export", "params": { "endpoint": "(your Neptune endpoint DNS name)", "profile": "neptune_ml" }, "additionalParams": { "neptune_ml": { "version": "v2.0", "targets": [ (an array of node and edge class label targets) ], "features": [ (an array of node feature hints) ] } } }

对于 RDF 数据,其顶级结构可能如下所示:

{ "command": "export-rdf", "outputS3Path": "s3://(your Amazon S3 bucket)/neptune-export", "params": { "endpoint": "(your Neptune endpoint DNS name)", "profile": "neptune_ml" }, "additionalParams": { "neptune_ml": { "version": "v2.0", "targets": [ (an array of node and edge class label targets) ] } } }

您还可以使用jobs字段:

{ "command": "export-pg", "outputS3Path": "s3://(your Amazon S3 bucket)/neptune-export", "params": { "endpoint": "(your Neptune endpoint DNS name)", "profile": "neptune_ml" }, "additionalParams" : { "neptune_ml" : { "version": "v2.0", "jobs": [ { "name" : "(training data configuration name)", "targets": [ (an array of node and edge class label targets) ], "features": [ (an array of node feature hints) ] }, { "name" : "(another training data configuration name)", "targets": [ (an array of node and edge class label targets) ], "features": [ (an array of node feature hints) ] } ] } } }

中的顶级元素neptune_ml字段additionalParams

这些区域有:version中的元素neptune_ml

指定要生成的训练数据配置的版本。

(可选),类型:字符串、默认值:“v2.0”。

如果你确实包括version,将其设置为v2.0.

这些区域有:jobs字段neptune_ml

包含一组训练数据配置对象,每个对象都定义了数据处理作业,并包含: