

我們不再更新 Amazon Machine Learning 服務或接受新使用者。本文件可供現有使用者使用，但我們不再更新。如需詳細資訊，請參閱[什麼是 Amazon Machine Learning](https://docs.aws.amazon.com/machine-learning/latest/dg/what-is-amazon-machine-learning.html)。

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

# 搭配使用 Amazon S3 與 Amazon ML
<a name="using-amazon-s3-with-amazon-ml"></a>

Amazon Simple Storage Service (Amazon S3) 是網際網路儲存服務。您可以使用 Amazon S3 隨時從 Web 任何地方存放和擷取任意資料量。Amazon ML 使用 Amazon S3 做為下列任務的主要資料儲存庫：
+ 存取輸入檔案以建立資料來源物件，藉此訓練和評估 ML 模型。
+ 存取輸入檔來產生批次預測。
+ 使用 ML 模型產生批次預測時，將所指定的 S3 儲存貯體輸出到預測檔案。
+ 若要將儲存在 Amazon Redshift 或 Amazon Relational Database Service (Amazon RDS) 中的資料複製到 .csv 檔案，並將其上傳至 Amazon S3。

若要讓 Amazon ML 執行這些任務，您必須授予 Amazon ML 存取 Amazon S3 資料的許可。

**注意**  
您不能將批次預測的檔案輸出到僅接受伺服器端加密的 S3 儲存貯體。在請求中沒有 `Deny` 標題的情況下，請確定儲存貯體政策中沒有 `s3:PutObject` 動作的 `s3:x-amz-server-side-encryption` 效果，就能確認該政策允許上傳未加密的檔案。如需 S3 伺服器端加密儲存貯體政策的詳細資訊，請參閱《[https://docs.aws.amazon.com/AmazonS3/latest/userguide/](https://docs.aws.amazon.com/AmazonS3/latest/userguide/)》中的[使用伺服器端加密保護資料](https://docs.aws.amazon.com/AmazonS3/latest/userguide/serv-side-encryption.html)。

## 將您的資料上傳至 Amazon S3
<a name="uploading-your-data-to-amazon-s3"></a>

您必須將輸入資料上傳至 Amazon Simple Storage Service (Amazon S3)，因為 Amazon ML 從 Amazon S3 位置讀取資料。您可以直接將資料上傳至 Amazon S3 （例如，從您的電腦），或者 Amazon ML 可以將存放在 Amazon Redshift 或 Amazon Relational Database Service (RDS) 中的資料複製到 .csv 檔案中，並將其上傳至 Amazon S3。

如需從 Amazon Redshift 或 Amazon RDS 複製資料的詳細資訊，請分別參閱[搭配 Amazon ML 使用 Amazon Redshift](https://docs.aws.amazon.com/machine-learning/latest/dg/using-amazon-redshift-with-amazon-ml.html) 或[搭配 Amazon ML 使用 Amazon RDS](https://docs.aws.amazon.com/machine-learning/latest/dg/using-amazon-rds-with-amazon-ml.html)。

本節的其餘部分說明如何將輸入資料直接從您的電腦上傳至 Amazon S3。在開始閱讀本節程序之前，您必須將資料轉成 .csv 檔案。如需有關如何正確格式化 .csv 檔案以便 Amazon ML 可以使用它的資訊，請參閱[了解 Amazon ML 的資料格式](https://docs.aws.amazon.com/machine-learning/latest/dg/understanding-the-data-format-for-amazon-ml.html)。

**將您的資料從電腦上傳至 Amazon S3**

1.  登入 AWS 管理主控台，然後前往 [https://console.aws.amazon.com/s3](https://console.aws.amazon.com/s3) 開啟 Amazon S3 主控台。

1.  建立儲存貯體或選擇現有的儲存貯體。

   1.  若要建立儲存貯體，請選擇 **Create Bucket (建立儲存貯體)**。為儲存貯體命名，選擇區域 (您可以選擇任何可用區域)，然後選擇 **Create (建立)**。如需詳細資訊，請參閱 [Amazon 簡易儲存入門指南](https://docs.aws.amazon.com/AmazonS3/latest/gsg/CreatingABucket.html)中的*建立儲存貯體*相關文章。

   1. 若要使用現有的儲存貯體，請從 **All Buckets (所有儲存貯體)** 清單中選擇儲存貯體，搜尋該儲存貯體。出現該儲存貯體的名稱後，選取其名稱，然後選擇 **Upload (上傳)**。

1. 在 **Upload (上傳)** 對話方塊中，選擇 **Add Files (新增檔案)**。

1. 導覽到其中包含輸入資料 .csv 檔案的資料夾，然後選擇 **Open (開啟)**。

## 許可
<a name="w2aac16c25c12"></a>

若要授予 Amazon ML 存取其中一個 S3 儲存貯體的許可，您必須編輯儲存貯體政策。

如需有關授予 Amazon ML 許可以從 Amazon S3 中的儲存貯體讀取資料的資訊，請參閱[授予 Amazon ML 許可以從 Amazon S3 讀取您的資料](https://docs.aws.amazon.com/machine-learning/latest/dg/granting-amazon-ml-permissions-to-read-your-data-from-amazon-s3.html)。

如需授予 Amazon ML 許可以將批次預測結果輸出至 Amazon S3 中儲存貯體的詳細資訊，請參閱[授予 Amazon ML 許可以將預測輸出至 Amazon S3](https://docs.aws.amazon.com/machine-learning/latest/dg/granting-amazon-ml-permissions-to-output-predictions-to-amazon-s3.html)。

如需有關管理 Amazon S3 資源存取許可的資訊，請參閱 [Amazon S3 開發人員指南](https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-access-control.html)。