

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

# 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 经典版中克隆 Git 存储库](studio-tasks-git.md)。


| **使用案例** | **描述** | 
| --- | --- | 
| [无服务器推理](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 会检查您的数据集，并运行多个候选模型，以找出数据预处理步骤、机器学习算法和超参数的最佳组合。您可以轻松地将其部署在实时端点，也可用于批量处理。 在某些情况下，您可能希望能够灵活地将自定义数据处理代码引入 Autopilot。例如，您的数据集可能包含大量自变量，您可能希望加入一个自定义特征选择步骤，以便首先移除不相关的变量。这样得到的较小的数据集可用于启动 Autopilot 作业。最终，您可能还希望包括自定义处理代码和来自 Autopilot 的模型，以进行实时或批量处理。  | 
|  [管道示例](https://github.com/aws/amazon-sagemaker-examples/tree/main/autopilot/sagemaker-autopilot-pipelines)  |  虽然 Autopilot 简化了构建 ML 模型的过程，但 MLOps 工程师仍负责在生产环境中创建、自动化和管理端到端 ML 工作流。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) 或[处理](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/)。 或者，在[组合模式下](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 作为原生步骤，您现在可以在 Pipelines 中添加自动训练步骤 ([AutoMLStep](https://docs.aws.amazon.com/sagemaker/latest/dg/build-and-manage-steps.html#step-type-automl))，然后在组合模式下调用 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 的财务结果时，如何考虑预测错误的相对成本。  | 
| [利用 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)等。 | 