

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

# Amazon SageMaker Autopilot 範例筆記本
<a name="autopilot-example-notebooks"></a>

下列筆記本提供可處理 Autopilot 各種使用案例的實用實作範例。

您可以在 SageMaker AI GitHub 範例儲存庫的 [https://github.com/aws/amazon-sagemaker-examples/tree/main/autopilot](https://github.com/aws/amazon-sagemaker-examples/tree/main/autopilot) 目錄中找到 Autopilot 的所有筆記本。

我們建議您在 Studio Classic 內複製完整 Git 儲存庫，以直接存取並執行筆記本。如需如何在 Studio Classic 中複製 Git 儲存庫的資訊，請參閱[複製 Amazon SageMaker Studio Classic 中的 Git 儲存庫](studio-tasks-git.md)。


| **使用案例** | **Description** | 
| --- | --- | 
| [無伺服器推論](https://github.com/aws/amazon-sagemaker-examples/tree/main/autopilot/autopilot-serverless-inference) | 根據預設，Autopilot 可讓您將產生的模型部署到即時推論端點。在這個儲存庫中，筆記本會說明如何將使用 `ENSEMBLING` 和 `HYPERPARAMETER OPTIMIZATION (HPO)` 模式訓練的 Autopilot 模型部署到無伺服器端點。無伺服器端點會自動啟動運算資源，並根據流量進行縮減與擴增，無需選擇執行個體類型或管理擴展政策。 | 
| [自訂功能選擇](https://github.com/aws/amazon-sagemaker-examples/tree/main/autopilot/custom-feature-selection) | Autopilot 會檢查您的資料集並執行多個候選項目，以找出資料預先處理步驟、機器學習演算法和超參數的最佳組合。您可以輕鬆部署在即時端點上或進行批次處理。<br />在某些情況下，您可能希望將自訂資料處理程式碼提供給 Autopilot 時具有彈性。例如，您的資料集可能包含大量獨立變數，您可能希望合併自訂功能選擇步驟，先移除不相關的變數。然後，可以使用產生的較小型資料集啟動一個 Autopilot 任務。最後，您還希望同時包含 Autopilot 的自訂處理程式碼和模型，進行即時或批次處理。 | 
| [Pipeline 範例](https://github.com/aws/amazon-sagemaker-examples/tree/main/autopilot/sagemaker-autopilot-pipelines) | 雖然 Autopilot 精簡機器學習 (ML) 模型建置程序，但 MLOps 工程師仍然需要負責在生產中建立、自動化和管理端對端機器學習工作流程。SageMaker Pipelines 可協助自動化機器學習 (ML) 生命週期的各個步驟，例如資料預先處理、模型訓練、超參數調校、模型評估和部署。這個筆記本示範如何將 Autopilot 合併到 SageMaker Pipelines 端對端 AutoML 訓練工作流程。若要在 Pipelines 內啟動 Autopilot 實驗，您必須使用 Pipelines [Lambda](https://docs.aws.amazon.com/sagemaker/latest/dg/build-and-manage-steps.html#step-type-lambda) 或 [Processing](https://docs.aws.amazon.com/sagemaker/latest/dg/build-and-manage-steps.html#step-type-processing) 步驟寫入自訂整合程式碼，才能建立模型建置工作流程。如需詳細資訊，請參閱[使用 Amazon SageMaker Pipelines 將 Amazon SageMaker Autopilot ML 模型從實驗遷移至生產](https://aws.amazon.com/blogs/machine-learning/move-amazon-sagemaker-autopilot-ml-models-from-experimentation-to-production-using-amazon-sagemaker-pipelines/)。<br />或者，在[集成模式](https://docs.aws.amazon.com/sagemaker/latest/dg/autopilot-model-support-validation.html)下使用 Autopilot 時，您可以參考筆記本範例，這個筆記本範例會示範如何使用 [SageMaker 管道原生 AutoML 步驟](https://github.com/aws/amazon-sagemaker-examples/blob/main/autopilot/sagemaker-autopilot-pipelines/autopilot_pipelines_demo_notebook.ipynb)中的原生 AutoML 步驟。使用 Pipelines 內做為原生步驟支援的 Autopilot，您就可以立即將自動化訓練步驟 ([AutoMLStep](https://docs.aws.amazon.com/sagemaker/latest/dg/build-and-manage-steps.html#step-type-automl)) 新增至 Pipelines，並在集成模式下調用 Autopilot 實驗。 | 
| [使用 Amazon SageMaker Autopilot 進行直接行銷](https://sagemaker-examples.readthedocs.io/en/latest/autopilot/sagemaker_autopilot_direct_marketing.html) | 此筆記本示範如何使用[銀行行銷資料集](https://archive.ics.uci.edu/ml/datasets/bank+marketing)，預測客戶是否會加入銀行的定期存款。您可以在此資料集上使用 Autopilot，探索各種管道候選項目所包含的選項以取得最準確的機器學習 (ML) 管道。Autopilot 會在雙步驟的程序中產生每個候選項目。第一個步驟會在資料集上執行自動化功能工程設計。第二個步驟會訓練並調校演算法以產生模型。此筆記本包含說明如何訓練模型以及如何部署模型，以使用最佳候選項目執行批次推論的相關指示。 | 
| [使用 Amazon SageMaker Autopilot 進行客戶流失預測](https://sagemaker-examples.readthedocs.io/en/latest/autopilot/autopilot_customer_churn.html) | 此筆記本描述使用機器學習 (ML) 來自動識別不滿意的客戶，此功能也稱為客戶流失預測。此範例說明如何分析可公開取得的資料集，以及在該資料集上執行功能工程設計。接著，它說明如何選取最佳效能的管道以及訓練演算法的最佳超參數來調校模型。最後，它說明如何將模型部署到託管端點，並根據基本事實如何評估其預測。但是，機器學習 (ML) 模型很少給出完美的預測。這就是這個筆記本也在說明如何在確定使用機器學習 (ML) 的財務結果時，合併預測錯誤之相對成本的原因。 | 
| [使用 Amazon SageMaker Autopilot 和批次轉換進行最佳候選客戶流失預測 (Python SDK)](https://sagemaker-examples.readthedocs.io/en/latest/autopilot/autopilot_customer_churn_high_level_with_evaluation.html) | 此筆記本也描述使用機器學習來自動識別不滿意的客戶，此功能也稱為客戶流失預測。這個筆記本示範如何設定模型以取得推論機率、選取前 N 個模型，以及在保留測試集上進行批次轉換以進行評估。 這個筆記本使用 2020 年 6 月 19 日發行的 SageMaker Python SDK >= 1.65.1。  | 
| [將您自己的資料處理程式碼帶入 Amazon SageMaker Autopilot](https://sagemaker-examples.readthedocs.io/en/latest/autopilot/custom-feature-selection/Feature_selection_autopilot.html) | 這個筆記本示範如何在使用 Amazon SageMaker Autopilot 時合併和部署自訂資料處理程式碼。它新增一個自訂功能選擇步驟，以移除與 Autopilot 任務不相關的變數。然後，它會示範如何在即時端點上部署 Autopilot 所產生的自訂處理程式碼和模型，或者，進行批次處理。 | 
| 更多筆記本 | 您可以在根目錄中找到更多說明其他使用案例的筆記本，例如[批次轉換](https://github.com/aws/amazon-sagemaker-examples/blob/main/autopilot/ap-batch-transform.ipynb)、[時間序列預測](https://github.com/aws/amazon-sagemaker-examples/blob/main/autopilot/autopilot_time_series.ipynb)等。 | 