您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

使用 Azure 机器学习设计器运行批量预测Run batch predictions using Azure Machine Learning designer

本文介绍如何使用设计器创建批量预测管道。In this article, you learn how to use the designer to create a batch prediction pipeline. 借助批量预测,可以使用可从任何 HTTP 库触发的 Web 服务按需对大型数据集持续评分。Batch prediction lets you continuously score large datasets on-demand using a web service that can be triggered from any HTTP library.

在本操作指南中,你将了解如何执行以下任务:In this how-to, you learn to do the following tasks:

  • 创建并发布批量推理管道Create and publish a batch inference pipeline
  • 使用管道终结点Consume a pipeline endpoint
  • 管理终结点版本Manage endpoint versions

要了解如何使用 SDK 设置批量评分服务,请参阅随附的操作指南To learn how to set up batch scoring services using the SDK, see the accompanying how-to.


本操作指南假设你已有一个训练管道。This how-to assumes you already have a training pipeline. 有关设计器的引导式简介,请完成设计器教程的第一部分For a guided introduction to the designer, complete part one of the designer tutorial.


如果看不到本文档中提到的图形元素(例如工作室或设计器中的按钮),则你可能没有适当级别的工作区权限。If you do not see graphical elements mentioned in this document, such as buttons in studio or designer, you may not have the right level of permissions to the workspace. 请与 Azure 订阅管理员联系,验证是否已向你授予正确级别的访问权限。Please contact your Azure subscription administrator to verify that you have been granted the correct level of access. 有关详细信息,请参阅管理用户和角色For more information, see Manage users and roles.

创建批量推理管道Create a batch inference pipeline

必须至少运行一次训练管道,才能创建推理管道。Your training pipeline must be run at least once to be able to create an inferencing pipeline.

  1. 转到工作区中的“设计器”选项卡。Go to the Designer tab in your workspace.

  2. 选择训练管道,将使用它训练要用来进行预测的模型。Select the training pipeline that trains the model you want to use to make prediction.

  3. “提交”管道。Submit the pipeline.


训练管道已运行,现在可以创建批量推理管道了。Now that the training pipeline has been run, you can create a batch inference pipeline.

  1. 在“提交”旁边,选择新的下拉菜单“创建推理管道”。Next to Submit, select the new dropdown Create inference pipeline.

  2. 选择“批量推理管道”。Select Batch inference pipeline.


结果为默认批量推理管道。The result is a default batch inference pipeline.

添加管道参数Add a pipeline parameter

要创建对新数据的预测,可以手动连接此管道草稿视图中的不同数据集,也可以创建数据集的参数。To create predictions on new data, you can either manually connect a different dataset in this pipeline draft view or create a parameter for your dataset. 通过参数可以在运行时更改批量推理过程的行为。Parameters let you change the behavior of the batch inferencing process at runtime.

在本节中,你将创建一个数据集参数,以便指定要进行预测的不同目标数据集。In this section, you create a dataset parameter to specify a different dataset to make predictions on.

  1. 选择数据集模块。Select the dataset module.

  2. 画布右侧将显示一个窗格。A pane will appear to the right of the canvas. 在窗格底部,选择“设置为管道参数”。At the bottom of the pane, select Set as pipeline parameter.

    输入参数名称或接受默认值。Enter a name for the parameter, or accept the default value.

    将数据集设置为管道参数Set dataset as pipeline parameter

发布批量推理管道Publish your batch inference pipeline

现已准备好部署推理管道。Now you're ready to deploy the inference pipeline. 下面的操作将部署管道,使其可供其他人使用。This will deploy the pipeline and make it available for others to use.

  1. 选择“发布”按钮。Select the Publish button.

  2. 在出现的对话框中,展开“PipelineEndpoint”的下拉菜单,然后选择“新建 PipelineEndpoint”。In the dialog that appears, expand the drop-down for PipelineEndpoint, and select New PipelineEndpoint.

  3. 提供终结点名称和可选说明。Provide an endpoint name and optional description.

    在对话框底部附近,可以看到使用训练期间所用的数据集 ID 默认值配置的参数。Near the bottom of the dialog, you can see the parameter you configured with a default value of the dataset ID used during training.

  4. 选择“发布”。Select Publish.


使用终结点Consume an endpoint

现在,你已有一个带数据集参数的已发布管道。Now, you have a published pipeline with a dataset parameter. 管道将使用在训练管道中创建的训练模型,对作为参数提供的数据集进行评分。The pipeline will use the trained model created in the training pipeline to score the dataset you provide as a parameter.

提交管道运行Submit a pipeline run

在本节中,你将设置手动管道运行,并修改管道参数,以便对新数据评分。In this section, you will set up a manual pipeline run and alter the pipeline parameter to score new data.

  1. 部署完成后,转到“终结点”部分。After the deployment is complete, go to the Endpoints section.

  2. 选择“管道终结点”。Select Pipeline endpoints.

  3. 选择你创建的终结点的名称。Select the name of the endpoint you created.


  1. 选择“已发布管道”。Select Published pipelines.

    此屏幕显示此终结点下的所有已发布管道。This screen shows all published pipelines published under this endpoint.

  2. 选择已发布的管道。Select the pipeline you published.

    “管道详细信息”页显示管道的详细运行历史记录和连接字符串信息。The pipeline details page shows you a detailed run history and connection string information for your pipeline.

  3. 选择“提交”创建管道的手动运行。Select Submit to create a manual run of the pipeline.


  4. 更改参数以使用不同的数据集。Change the parameter to use a different dataset.

  5. 选择“提交”运行管道。Select Submit to run the pipeline.

使用 REST 终结点Use the REST endpoint

可以在“终结点”部分中找到有关如何使用管道终结点和已发布管道的信息。You can find information on how to consume pipeline endpoints and published pipeline in the Endpoints section.

在“运行概述”面板中可以找到管道终结点的 REST 终结点。You can find the REST endpoint of a pipeline endpoint in the run overview panel. 通过调用终结点,将使用其默认的已发布管道。By calling the endpoint, you are consuming its default published pipeline.

另外,还可以在“已发布管道”页中使用已发布的管道。You can also consume a published pipeline in the Published pipelines page. 选择一个已发布的管道,然后就可以在图右侧的“已发布管道概览”面板中找到该管道的 REST 终结点。Select a published pipeline and you can find the REST endpoint of it in the Published pipeline overview panel to the right of the graph.

若要进行 REST 调用,需要 OAuth 2.0 持有者类型身份验证标头。To make a REST call, you will need an OAuth 2.0 bearer-type authentication header. 请参阅以下教程部分,以详细了解如何设置工作区的身份验证并进行参数化 REST 调用。See the following tutorial section for more detail on setting up authentication to your workspace and making a parameterized REST call.

版本控制终结点Versioning endpoints

设计器将版本分配给你发布到终结点的每个后续管道。The designer assigns a version to each subsequent pipeline that you publish to an endpoint. 可以在 REST 调用中指定要作为参数执行的管道版本。You can specify the pipeline version that you want to execute as a parameter in your REST call. 如果不指定版本号,设计器将使用默认管道。If you don't specify a version number, the designer will use the default pipeline.

在发布管道时,可以选择将其设为该终结点的新默认管道。When you publish a pipeline, you can choose to make it the new default pipeline for that endpoint.


另外,还可以在终结点的“已发布管道”选项卡中设置新的默认管道。You can also set a new default pipeline in the Published pipelines tab of your endpoint.



如果在训练管道中进行了一些修改,则应重新提交该训练管道,“更新”推理管道并重新运行该推理管道。If you make some modifications in your training pipeline, you should re-submit the training pipeline, Update the inference pipeline and run the inference pipeline again.

请注意,推理管道中只会更新模型,而不会更新数据转换。Note that only models will be updated in the inference pipeline, while data transformation will not be updated.

若要在推理管道中使用更新的转换,需要将转换模块的转换输出注册为数据集。To use the updated transformation in inference pipeline, you need to register the transformation output of the transformation module as dataset.


然后,手动将推理管道中的 TD 模块替换为已注册的数据集。Then manually replace the TD- module in inference pipeline with the registered dataset.


然后,即可提交模型和转换均已更新的推理管道,并进行发布。Then you can submit the inference pipeline with the updated model and transformation, and publish.

后续步骤Next steps

按照设计器教程训练和部署回归模型。Follow the designer tutorial to train and deploy a regression model.

若要了解如何使用 SDK 来发布管道以及如何运行已发布的管道,请参阅此文For how to publish and run a published pipeline using SDK, see this article.