

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

# 下载调试器 XGBoost 培训报告
<a name="debugger-training-xgboost-report-download"></a>

使用 [Amaz SageMaker on Python SDK](https://sagemaker.readthedocs.io/en/stable) 和 Amazon Command Line Interface (CLI) 在训练作业运行时或任务完成后下载调试器 XGBoost 训练报告。

------
#### [ Download using the SageMaker Python SDK and Amazon CLI ]

1. 检查当前作业的默认 S3 输出基础 URI。

   ```
   estimator.output_path
   ```

1. 检查当前作业名称。

   ```
   estimator.latest_training_job.job_name
   ```

1. 调试器 XGBoost 报告存储在`<default-s3-output-base-uri>/<training-job-name>/rule-output`。如下所示配置规则输出路径：

   ```
   rule_output_path = estimator.output_path + "/" + estimator.latest_training_job.job_name + "/rule-output"
   ```

1. 要检查报告是否已生成，请在 `rule_output_path` 下，使用 `aws s3 ls` 以及 `--recursive` 选项递归列出目录和文件。

   ```
   ! aws s3 ls {rule_output_path} --recursive
   ```

   这应返回自动生成的文件夹（名为 `CreateXgboostReport` 和 `ProfilerReport-1234567890`）下的文件完整列表。 XGBoost 训练报告存储在中`CreateXgboostReport`，分析报告存储在`ProfilerReport-1234567890`文件夹中。要了解有关 XGBoost训练作业默认生成的分析报告的更多信息，请参阅[SageMaker 调试器交互式报告](debugger-profiling-report.md)。  
![\[规则输出的示例。\]](http://docs.amazonaws.cn/sagemaker/latest/dg/images/debugger/debugger-xgboost-report-ls.png)

   `xgboost_report.html`是 Debugger 自动生成的 XGBoost 训练报告。`xgboost_report.ipynb` 是一个 Jupyter 笔记本，用于将训练结果聚合到报告中。您可以下载所有文件、浏览 HTML 报告文件，并使用笔记本修改报告。

1. 使用 `aws s3 cp` 递归下载文件。以下命令将所有规则输出文件保存到 `ProfilerReport-1234567890` 文件夹下的当前工作目录中。

   ```
   ! aws s3 cp {rule_output_path} ./ --recursive
   ```
**提示**  
如果您使用的是 Jupyter 笔记本服务器，请运行 `!pwd` 以验证当前的工作目录。

1. 在 `/CreateXgboostReport` 目录下，打开 `xgboost_report.html`。如果您正在使用 JupyterLab，请选择 T **rust HTML** 以查看自动生成的调试器训练报告。  
![\[规则输出的示例。\]](http://docs.amazonaws.cn/sagemaker/latest/dg/images/debugger/debugger-xgboost-report-open-trust.png)

1. 打开 `xgboost_report.ipynb` 文件以浏览报告的生成方式。您可以使用 Jupyter 笔记本文件自定义和扩展训练报告。

------
#### [ Download using the Amazon S3 console ]

1. 登录 Amazon Web Services 管理控制台 并打开 Amazon S3 控制台，网址为[https://console.aws.amazon.com/s3/](https://console.amazonaws.cn/s3/)。

1. 搜索基本 S3 存储桶。例如，如果您尚未指定任何基本作业名称，则基本 S3 存储桶名称应采用以下格式：`sagemaker-<region>-111122223333`。通过**按名称查找存储桶**字段，查找基本 S3 存储桶。  
![\[Amazon S3 控制台中的“按名称查找存储桶”字段。\]](http://docs.amazonaws.cn/sagemaker/latest/dg/images/debugger/debugger-report-download-s3console-0.png)

1. 在基本 S3 存储桶中，在**按前缀查找对象**中输入您的作业名称前缀来查找训练作业名称，然后选择训练作业名称。  
![\[Amazon S3 控制台中的“按前缀查找对象”字段。\]](http://docs.amazonaws.cn/sagemaker/latest/dg/images/debugger/debugger-report-download-s3console-1.png)

1. 在训练作业的 S3 存储桶中，选择 **rule-output/** 子文件夹。对于 Debugger 收集的训练数据，必须要有三个子文件夹：**debug-output/**、**profiler-output/** 和 **rule-output/**。  
![\[规则输出 S3 存储桶 URI 的示例。\]](http://docs.amazonaws.cn/sagemaker/latest/dg/images/debugger/debugger-report-download-s3console-2.png)

1. **在 **rule-output/ 文件夹中，选择/**文件夹。CreateXgboostReport**文件夹中包含 **xbgoost\$1report.html**（自动生成的报告，html 格式）和 **xbgoost\$1report.ipynb**（用于生成报告的 Jupyter 笔记本和脚本）。

1. 选择 **xbgoost\$1report.html** 文件，选择**下载操作**，然后选择**下载**。  
![\[规则输出 S3 存储桶 URI 的示例。\]](http://docs.amazonaws.cn/sagemaker/latest/dg/images/debugger/debugger-xgboost-report-s3-download.png)

1. 在 Web 浏览器中打开下载的 **xbgoost\$1report.html** 文件。

------