使用 neptune-export 工具或 Neptune-Export 服務,從 Neptune ML 的 Neptune 中匯出資料 - Amazon Neptune

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

使用 neptune-export 工具或 Neptune-Export 服務,從 Neptune ML 的 Neptune 中匯出資料

Neptune ML 需要您為 Deep Graph Library (DGL) 提供訓練資料,以建立和評估模型。

您可以使用 Neptune-Export 服務neptune-export 公用程式,從 Neptune 中匯出資料。此服務和命令列工具兩者都會以 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 – 必須將 params 物件中的 profile 欄位設為 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) ] } ] } } }

additionalParamsneptune_ml 欄位內的最上層元素

neptune_ml中的 version 元素

指定要產生的訓練資料組態版本。

(選用),類型:字串,預設值:「v2.0」。

如果確實包含 version,請將其設為 v2.0

neptune_ml 中的 jobs 欄位

包含訓練資料組態物件的陣列,每個物件都會定義資料處理工作,並包含:

  • name – 要建立的訓練資料組態名稱。

    例如,名稱為「job-number-1」的訓練資料組態會產生一個名為 job-number-1.json 的訓練資料組態檔案。

  • targets – 節點和邊緣類別標籤目標的 JSON 陣列,這些目標代表供訓練用途的機器學習類別標籤。請參閱 neptune_ml 物件中的 targets 欄位

  • features – 節點屬性特徵的 JSON 陣列。請參閱neptune_ml 中的 features 欄位