部署 Azure 机器学习工作室(经典)Web 服务Deploy an Azure Machine Learning Studio (classic) web service

适用于: yes机器学习工作室(经典) noAzure 机器学习APPLIES TO: yesMachine Learning Studio (classic) noAzure Machine Learning

可以使用 Azure 机器学习工作室(经典)构建和测试预测分析解决方案。Azure Machine Learning Studio (classic) enables you to build and test a predictive analytic solution. 然后,可以将该解决方案部署为 Web 服务。Then you can deploy the solution as a web service.

机器学习工作室(经典)Web 服务提供了应用程序与机器学习工作室(经典)工作流评分模型之间的接口。Machine Learning Studio (classic) web services provide an interface between an application and a Machine Learning Studio (classic) workflow scoring model. 外部应用程序可以实时与机器学习工作室(经典)工作流评分模型进行通信。An external application can communicate with a Machine Learning Studio (classic) workflow scoring model in real time. 调用机器学习工作室(经典)Web 服务可将预测结果返回外部应用程序。A call to a Machine Learning Studio (classic) web service returns prediction results to an external application. 若要调用 Web 服务,需要在传递部署 Web 服务时创建的 API 密钥。To make a call to a web service, you pass an API key that was created when you deployed the web service. 机器学习工作室(经典)Web 服务基于 REST,后者是用于 Web 编程项目的一种流行的体系结构。A Machine Learning Studio (classic) web service is based on REST, a popular architecture choice for web programming projects.

Azure 机器学习工作室(经典)有两种类型的 Web 服务:Azure Machine Learning Studio (classic) has two types of web services:

  • 请求响应服务 (RRS):一种低延迟且高度可缩放的服务,用于对单个数据记录进行评分。Request-Response Service (RRS): A low latency, highly scalable service that scores a single data record.
  • 批处理执行服务 (BES):对一批数据记录进行评分的一种异步服务。Batch Execution Service (BES): An asynchronous service that scores a batch of data records.

BES 的输入类似于 RRS 使用的数据输入。The input for BES is like data input that RRS uses. 主要区别在于,BES 读取的记录块来自多种源,例如 Azure Blob 存储、Azure 表存储、Azure SQL 数据库、HDInsight(Hive 查询)和 HTTP 源。The main difference is that BES reads a block of records from a variety of sources, such as Azure Blob storage, Azure Table storage, Azure SQL Database, HDInsight (hive query), and HTTP sources.

概括而言,可以通过以下三个步骤来部署模型:From a high-level point-of-view, you deploy your model in three steps:

  • 创建训练实验 - 在工作室(经典)中,你可以通过大量内置的机器学习算法使用你提供的训练数据来对预测分析模型进行训练和测试。Create a training experiment - In Studio (classic), you can train and test a predictive analytics model using training data that you supply, using a large set of built-in machine learning algorithms.
  • 将其转换为预测试验 - 利用现有数据定型模型后,你就可以使用它来对新数据进行评分,为预测准备并简化你的试验。Convert it to a predictive experiment - Once your model has been trained with existing data and you're ready to use it to score new data, you prepare and streamline your experiment for predictions.
  • 将其部署新 Web 服务经典 Web 服务 - 将预测实验部署为 Azure Web 服务时,用户可以将数据发送到模型并接收模型的预测。Deploy it as a New web service or a Classic web service - When you deploy your predictive experiment as an Azure web service, users can send data to your model and receive your model's predictions.

创建训练实验Create a training experiment

若要训练预测分析模型,请使用 Azure 机器学习工作室(经典)创建一个训练实验,其中包括加载训练数据、准备必要数据、应用机器学习算法和评估结果的各种模块。To train a predictive analytics model, you use Azure Machine Learning Studio (classic) to create a training experiment where you include various modules to load training data, prepare the data as necessary, apply machine learning algorithms, and evaluate the results. 可以迭代实验,尝试不同的机器学习算法来比较和评估结果。You can iterate on an experiment and try different machine learning algorithms to compare and evaluate the results.

在别处对创建和管理训练实验的过程进行了更详细地介绍。The process of creating and managing training experiments is covered more thoroughly elsewhere. 有关详细信息,请参阅以下文章:For more information, see these articles:

将训练实验转换为预测实验Convert the training experiment to a predictive experiment

模型训练完成后,便可以将训练实验转化为预测实验来对新数据进行评分。Once you've trained your model, you're ready to convert your training experiment into a predictive experiment to score new data.

通过转换为预测实验,可将训练的模型部署为评分 Web 服务。By converting to a predictive experiment, you're getting your trained model ready to be deployed as a scoring web service. Web 服务的用户会将输入的数据发送到模型,模型返回预测结果。Users of the web service can send input data to your model and your model will send back the prediction results. 转换为预测实验后,需记住自己期望别人如何使用模型。As you convert to a predictive experiment, keep in mind how you expect your model to be used by others.

将训练实验转换为预测实验的过程涉及三个步骤:The process of converting a training experiment to a predictive experiment involves three steps:

  1. 将机器学习算法模块替换为已训练模型。Replace the machine learning algorithm modules with your trained model.
  2. 仅对需要评分的模块的实验进行剪裁。Trim the experiment to only those modules that are needed for scoring. 训练实验包括训练所需的大量模块,但是一旦模型经过训练,则不再需要这些模块。A training experiment includes a number of modules that are necessary for training but are not needed once the model is trained.
  3. 定义模型如何接受 Web 服务用户提供的数据,以及返回什么样的数据。Define how your model will accept data from the web service user, and what data will be returned.

提示

在训练实验中,一直关注的是如何使用自己的数据对模型继续训练和评分。In your training experiment, you've been concerned with training and scoring your model using your own data. 但部署以后,用户会向模型发送新的数据,而该模型则会返回预测结果。But once deployed, users will send new data to your model and it will return prediction results. 因此,将训练实验转换为预测实验并使其可供部署以后,请关注他人会如何使用该模型。So, as you convert your training experiment to a predictive experiment to get it ready for deployment, keep in mind how the model will be used by others.

转换为评分实验

设置 Web 服务按钮Set Up Web Service button

运行实验(单击实验画布底部的“运行”)以后,请单击“设置 Web 服务”按钮(选择“预测 Web 服务”选项)。After you run your experiment (click RUN at the bottom of the experiment canvas), click the Set Up Web Service button (select the Predictive Web Service option). “设置 Web 服务”执行三个步骤,将训练实验转换为预测实验:Set Up Web Service performs for you the three steps of converting your training experiment to a predictive experiment:

  1. 它将已训练模型保存在模块调色板的“已训练模型”部分(位于实验画布左侧)。It saves your trained model in the Trained Models section of the module palette (to the left of the experiment canvas). 然后,它会将机器学习算法和训练模型模块替换为保存的已训练模型。It then replaces the machine learning algorithm and Train Model modules with the saved trained model.
  2. 它会分析实验,删除那些显然只用于训练且不再需要的模块。It analyzes your experiment and removes modules that were clearly used only for training and are no longer needed.
  3. 它会将 _Web 服务输入_和_输出_模块插入实验中的默认位置(这些模块接受并返回用户数据)。It inserts Web service input and output modules into default locations in your experiment (these modules accept and return user data).

例如,以下试验使用示例人口普查数据,训练双类提升的决策树模型:For example, the following experiment trains a two-class boosted decision tree model using sample census data:

训练实验

在此实验的模块执行四个基本上不同的函数:The modules in this experiment perform basically four different functions:

模块函数

将此训练实验转换为预测实验时,不再需要这些模块中的某些模块,因此会将其丢弃,或者让它们充当其他用途:When you convert this training experiment to a predictive experiment, some of these modules are no longer needed, or they now serve a different purpose:

  • 数据 - 在评分过程中不使用示例数据集中的数据 - web 服务的用户将提供要评分的数据。Data - The data in this sample dataset is not used during scoring - the user of the web service will supply the data to be scored. 但是,训练模型使用此数据集的元数据(如数据类型)。However, the metadata from this dataset, such as data types, is used by the trained model. 因此,需要将数据集保存在预测试验中,以便它可以提供此元数据。So you need to keep the dataset in the predictive experiment so that it can provide this metadata.

  • 准备 - 根据提交的、用于评分的用户数据,这些模块可能需要(也可能不需要)处理传入的数据。Prep - Depending on the user data that will be submitted for scoring, these modules may or may not be necessary to process the incoming data. “设置 Web 服务”按钮没有这些功能,需要确定如何处理它们。The Set Up Web Service button doesn't touch these - you need to decide how you want to handle them.

    例如,在此示例中,示例数据集可能有缺失值,因此提供了一个清理缺失数据模块来处理它们。For instance, in this example the sample dataset may have missing values, so a Clean Missing Data module was included to deal with them. 另外,示例数据集还包括训练该模型时不需要的列。Also, the sample dataset includes columns that are not needed to train the model. 因此提供选择数据集中的列模块,目的是从数据流中排除那些额外的列。So a Select Columns in Dataset module was included to exclude those extra columns from the data flow. 如果知道提交的、用于评分的数没有缺失值,则可以移除清理缺失数据模块。If you know that the data that will be submitted for scoring through the web service will not have missing values, then you can remove the Clean Missing Data module. 但是,由于选择数据集中的列模块可帮助定义已训练模型所期望的数据列,需要保留该模块。However, since the Select Columns in Dataset module helps define the columns of data that the trained model expects, that module needs to remain.

  • 训练 - 这些模块用于模型的训练。Train - These modules are used to train the model. 单击“设置 Web 服务”时,这些模块会被替换为单个模块,其中包含已训练的模型。When you click Set Up Web Service, these modules are replaced with a single module that contains the model you trained. 此新模块保存在模块调色板的“训练模型”部分。This new module is saved in the Trained Models section of the module palette.

  • 分数 - 在此示例中,拆分数据模块用于将数据流划分为测试数据和训练数据。Score - In this example, the Split Data module is used to divide the data stream into test data and training data. 在预测实验中,我们不再进行训练,因此可删除拆分数据In the predictive experiment, we're not training anymore, so Split Data can be removed. 同样,第二个评分模型模块和评估模型模块用于比较测试数据的结果,因此预测实验不需要这些模块。Similarly, the second Score Model module and the Evaluate Model module are used to compare results from the test data, so these modules are not needed in the predictive experiment. 然而,其余评分模型模块,就需要通过 Web 服务返回分数结果。The remaining Score Model module, however, is needed to return a score result through the web service.

单击“设置 Web 服务”示例如下所示:Here is how our example looks after clicking Set Up Web Service:

转换预测实验

要准备将实验部署为 Web 服务,“设置 Web 服务”所做的工作可能已经足够了。The work done by Set Up Web Service may be sufficient to prepare your experiment to be deployed as a web service. 但是,可能想要执行特定于试验的一些附加工作。However, you may want to do some additional work specific to your experiment.

调整输入和输出模块Adjust input and output modules

在训练实验中,使用定型数据集,并对其进行处理来获取窗体中机器学习算法所需的数据。In your training experiment, you used a set of training data and then did some processing to get the data in a form that the machine learning algorithm needed. 对于希望通过 Web 服务接收的数据,如果不需要上述处理,则可将其忽略:将“Web 服务输入模块”移动到试验中的另一个模块。If the data you expect to receive through the web service will not need this processing, you can bypass it: connect the output of the Web service input module to a different module in your experiment. 现在,用户的数据将到达此位置的模型。The user's data will now arrive in the model at this location.

例如,默认情况下“设置 Web 服务”将“Web 服务输入”模块置于数据流的顶部,如上图所示。For example, by default Set Up Web Service puts the Web service input module at the top of your data flow, as shown in the figure above. 不过,我们可以手动对“Web 服务输入”定位,使其通过数据处理模块:But we can manually position the Web service input past the data processing modules:

移动 web 服务输入

通过 web 服务提供的输入数据现在直接传递到分数模型模块,无需任何预处理。The input data provided through the web service will now pass directly into the Score Model module without any preprocessing.

相同地,默认情况下“设置 Web 服务”将“Web 服务输入”模块放置在数据的流顶部。Similarly, by default Set Up Web Service puts the Web service output module at the bottom of your data flow. 在此示例中,Web 服务将评分模型模块的输出返回给用户,其中包括完整的输入数据向量以及评分结果。In this example, the web service will return to the user the output of the Score Model module, which includes the complete input data vector plus the scoring results. 但是,若要返回与众不同的内容,则可在 Web 服务输出 模块之前添加其他模块。However, if you would prefer to return something different, then you can add additional modules before the Web service output module.

例如,若要仅返回输入数据的评分结果而不是整个向量,则可添加选择数据集中的列模块,以排除除计分结果之外的所有列。For example, to return only the scoring results and not the entire vector of input data, add a Select Columns in Dataset module to exclude all columns except the scoring results. 然后,将“Web 服务输出”模块移动到选择数据集中的列模块的输出。Then move the Web service output module to the output of the Select Columns in Dataset module. 该实验如下所示:The experiment looks like this:

移动 web 服务输出

添加或删除其他数据处理模块Add or remove additional data processing modules

如果知道在评分过程不再需要试验中的多个模块,则可以删除这些模块。If there are more modules in your experiment that you know will not be needed during scoring, these can be removed. 例如,由于在数据处理模块后已将“Web 服务输入”移动到点,可以删除预测实验中的清理缺失数据模块。For example, because we moved the Web service input module to a point after the data processing modules, we can remove the Clean Missing Data module from the predictive experiment.

现在,预测试验如下所示:Our predictive experiment now looks like this:

删除其他模块

添加其他 Web 服务参数Add optional Web Service Parameters

在某些情况下,可能希望 web 服务用户在访问该服务时可以更改模块的行为。In some cases, you may want to allow the user of your web service to change the behavior of modules when the service is accessed. Web 服务参数允许执行此操作。Web Service Parameters allow you to do this.

常见示例为设置导入数据模块,以便访问 Web 服务时,已部署的 Web 服务的用户能够指定其他数据源。A common example is setting up an Import Data module so the user of the deployed web service can specify a different data source when the web service is accessed. 或配置导出数据模块以指定其他目标。Or configuring an Export Data module so that a different destination can be specified.

可以定义 Web 服务参数并将其与一个或多个模块参数关联,可以指定它们是否是必需或可选。You can define Web Service Parameters and associate them with one or more module parameters, and you can specify whether they are required or optional. 访问该服务时,Web 服务的用户可为这些参数提供值,并可对模块操作进行相应的修改。The user of the web service provides values for these parameters when the service is accessed, and the module actions are modified accordingly.

有关 Web 服务参数是什么以及其使用方法的详细信息,请参阅使用 Azure 机器学习 Web 服务参数For more information about what Web Service Parameters are and how to use them, see Using Azure Machine Learning Web Service Parameters.

以下步骤描述如何将预测实验部署为新的 Web 服务。The following steps describe deploying a predictive experiment as a New web service. 还可将实验部署为经典 Web 服务。You can also deploy the experiment as Classic web service.

部署为新 Web 服务Deploy it as a New web service

现在,预测实验已准备就绪,可以将其部署为新的(基于资源管理器的)Azure Web 服务。Now that the predictive experiment has been prepared, you can deploy it as a new (Resource Manager-based) Azure web service. 使用 web 服务,用户可以将数据发送到模型,该模型将返回其预测。Using the web service, users can send data to your model and the model will return its predictions.

若要部署预测实验,请单击实验画布底部的“运行”。To deploy your predictive experiment, click Run at the bottom of the experiment canvas. 实验运行完毕后,单击“部署 Web 服务”或 部署 Web 服务全新Once the experiment has finished running, click Deploy Web Service and select Deploy Web Service New. 机器学习工作室(经典)Web 服务门户的部署页随即打开。The deployment page of the Machine Learning Studio (classic) Web Service portal opens.

备注

若要部署新的 Web 服务,必须对要部署 Web 服务的订阅拥有充分的权限。To deploy a New web service you must have sufficient permissions in the subscription to which you deploying the web service. 有关详细信息,请参阅使用 Azure 机器学习 Web 服务门户管理 Web 服务For more information see, Manage a Web service using the Azure Machine Learning Web Services portal.

Web 服务门户“部署试验”页Web Service portal Deploy Experiment Page

在“部署实验”页上,输入 Web 服务的名称。On the Deploy Experiment page, enter a name for the web service. 选择定价计划。Select a pricing plan. 如果有现有的定价计划,可以选择它,否则你必须为该服务创建新的定价计划。If you have an existing pricing plan you can select it, otherwise you must create a new price plan for the service.

  1. 在“定价计划”下拉菜单中选择一个现有计划,或选择“选择新计划”选项。In the Price Plan drop down, select an existing plan or select the Select new plan option.
  2. 在“计划名称”中,键入用于标识帐单上的计划的名称。In Plan Name, type a name that will identify the plan on your bill.
  3. 从“每月计划层”中选择一个计划层。Select one of the Monthly Plan Tiers. 计划层默认为默认区域的计划,并且 Web 服务将部署到该区域。The plan tiers default to the plans for your default region and your web service is deployed to that region.

单击“部署”和“快速入门”页面,打开 Web 服务。Click Deploy and the Quickstart page for your web service opens.

Web 服务快速入门页面提供了有关在创建 Web 服务后将执行的最常见任务的访问和指导。The web service Quickstart page gives you access and guidance on the most common tasks you will perform after creating a web service. 从此处,可以轻松访问测试页和使用页。From here, you can easily access both the Test page and Consume page.

测试新 Web 服务Test your New web service

若要测试新 Web 服务,请在常见任务下单击“测试 Web 服务”。To test your new web service, click Test web service under common tasks. 在测试页上,可将 Web 服务作为请求 - 响应服务 (RRS) 或 Batch 执行服务 (BES) 进行测试。On the Test page, you can test your web service as a Request-Response Service (RRS) or a Batch Execution service (BES).

RRS 测试页显示你为试验定义的输入、输出和任何全局参数。The RRS test page displays the inputs, outputs, and any global parameters that you have defined for the experiment. 若要测试 Web 服务,可手动输入适当的输入值,或提供包含测试值的逗号分隔值 (CSV) 格式的文件。To test the web service, you can manually enter appropriate values for the inputs or supply a comma separated value (CSV) formatted file containing the test values.

要使用 RRS 进行测试,请从列表视图模式中为输入键入适当的值,并单击“测试请求 - 响应”。To test using RRS, from the list view mode, enter appropriate values for the inputs and click Test Request-Response. 预测结果显示在左侧的输出列中。Your prediction results display in the output column to the left.

输入合适的值来测试 Web 服务

若要测试 BES,请单击“Batch”。To test your BES, click Batch. 在 Batch 测试页上,单击输入下的“浏览”,并选择包含相应示例值的 CSV 文件。On the Batch test page, click Browse under your input and select a CSV file containing appropriate sample values. 如果没有 CSV 文件,并且已使用机器学习工作室(经典)创建了预测试验,则可以下载预测试验的数据集并使用它。If you don't have a CSV file, and you created your predictive experiment using Machine Learning Studio (classic), you can download the data set for your predictive experiment and use it.

若要下载数据集,请打开机器学习工作室(经典)。To download the data set, open Machine Learning Studio (classic). 打开预测实验,右键单击实验的输入。Open your predictive experiment and right click the input for your experiment. 从上下文菜单中,选择“数据集”,并选择“下载”。From the context menu, select dataset and then select Download.

从工作室(经典)画布下载数据集

单击“测试”。Click Test. Batch 执行作业的状态显示在“测试 Batch 作业”的下方。The status of your Batch Execution job displays to the right under Test Batch Jobs.

使用 Web 服务门户测试 Batch 执行作业

在“配置”页上,可更改描述、标题,更新存储帐户密钥,以及启用 Web 服务的示例数据。On the CONFIGURATION page, you can change the description, title, update the storage account key, and enable sample data for your web service.

配置 Web 服务

访问新 Web 服务Access your New web service

从机器学习工作室(经典)部署 Web 服务后,可以采用编程方式向服务发送数据并接收响应。Once you deploy your web service from Machine Learning Studio (classic), you can send data to the service and receive responses programmatically.

使用页提供访问 Web 服务所需的所有信息。The Consume page provides all the information you need to access your web service. 例如,提供 API 密钥以允许对服务的授权访问。For example, the API key is provided to allow authorized access to the service.

有关访问机器学习工作室(经典)Web 服务的详细信息,请参阅如何使用 Azure 机器学习工作室(经典)Web 服务For more information about accessing a Machine Learning Studio (classic) web service, see How to consume an Azure Machine Learning Studio (classic) Web service.

管理新 Web 服务Manage your New web service

可以通过机器学习工作室(经典)Web 服务门户管理新的 Web 服务。You can manage your New web services using Machine Learning Studio (classic) Web Services portal. 主门户页中,单击“Web 服务”。From the main portal page, click Web Services. 在 Web 服务页中,可删除或复制服务。From the web services page, you can delete or copy a service. 要监视特定服务,请单击该服务,并单击“仪表板”。To monitor a specific service, click the service and then click Dashboard. 若要监视与 Web 服务相关联的 Batch 作业,请单击“Batch 请求日志”。To monitor batch jobs associated with the web service, click Batch Request Log.

将新的 Web 服务部署到多个区域Deploy your New web service to multiple regions

无需多个订阅或工作区即可轻松地将新的 Web 服务部署到多个区域。You can easily deploy a New web service to multiple regions without needing multiple subscriptions or workspaces.

定价因区域而异,因此你需要为要在其中部署 Web 服务的每个区域定义收费计划。Pricing is region specific, so you need to define a billing plan for each region in which you will deploy the web service.

在另一个区域中创建计划Create a plan in another region

  1. 登录到 Microsoft Azure 机器学习 Web 服务Sign in to Microsoft Azure Machine Learning Web Services.
  2. 单击“计划”菜单选项。Click the Plans menu option.
  3. 在视图页中的“计划”上,单击“新建”。On the Plans over view page, click New.
  4. 从“订阅”下拉列表中,选择新计划将驻留的订阅。From the Subscription dropdown, select the subscription in which the new plan will reside.
  5. 从“区域”下拉列表中,选择适用于新计划的区域。From the Region dropdown, select a region for the new plan. 所选区域的“计划选项”会显示在该页的“计划选项”部分中。The Plan Options for the selected region will display in the Plan Options section of the page.
  6. 从“资源组”下拉列表中,选择适用于该计划的资源组。From the Resource Group dropdown, select a resource group for the plan. 有关资源组的详细信息,请参阅 Azure 资源管理器概述From more information on resource groups, see Azure Resource Manager overview.
  7. 在“计划名称”中,键入计划的名称。In Plan Name type the name of the plan.
  8. 在“计划选项”中,单击新计划的计费级别。Under Plan Options, click the billing level for the new plan.
  9. 单击创建Click Create.

将 Web 服务部署到另一个区域Deploy the web service to another region

  1. 在 Microsoft Azure 机器学习 Web 服务页上,单击“Web 服务”菜单选项。On the Microsoft Azure Machine Learning Web Services page, click the Web Services menu option.
  2. 选择要部署到新区域的 Web 服务。Select the Web Service you are deploying to a new region.
  3. 单击 “复制”Click Copy.
  4. 在“Web 服务名称”中,键入 Web 服务的新名称。In Web Service Name, type a new name for the web service.
  5. 在“Web 服务描述”中,键入 Web 服务的描述。In Web service description, type a description for the web service.
  6. 从“订阅”下拉列表中,选择新的 Web 服务将驻留的订阅。From the Subscription dropdown, select the subscription in which the new web service will reside.
  7. 从“资源组”下拉列表中,选择适用于该 Web 服务的资源组。From the Resource Group dropdown, select a resource group for the web service. 有关资源组的详细信息,请参阅 Azure 资源管理器概述From more information on resource groups, see Azure Resource Manager overview.
  8. 从“区域”下拉列表中,选择要部署 Web 服务的区域。From the Region dropdown, select the region in which to deploy the web service.
  9. 从“存储帐户”下拉列表中,选择要存储 Web 服务的存储帐户。From the Storage account dropdown, select a storage account in which to store the web service.
  10. 从“价格计划”下拉列表中,选择步骤 8 中所选的区域中的计划。From the Price Plan dropdown, select a plan in the region you selected in step 8.
  11. 单击 “复制”Click Copy.

部署为经典 Web 服务Deploy it as a Classic web service

现在,已充分准备好预测试验,可将其部署为经典 Azure Web 服务。Now that the predictive experiment has been sufficiently prepared, you can deploy it as a Classic Azure web service. 使用 web 服务,用户可以将数据发送到模型,该模型将返回其预测。Using the web service, users can send data to your model and the model will return its predictions.

要部署预测实验,请单击实验画布底部的“运行”,并单击“部署 Web 服务”。To deploy your predictive experiment, click Run at the bottom of the experiment canvas and then click Deploy Web Service. 已设置 Web 服务,现在正位于 Web 服务仪表板中。The web service is set up and you are placed in the web service dashboard.

从工作室(经典)部署 Web 服务

测试经典 Web 服务Test your Classic web service

可在机器学习工作室(经典)Web 服务门户或机器学习工作室(经典)中测试 Web 服务。You can test the web service in either the Machine Learning Studio (classic) Web Services portal or Machine Learning Studio (classic).

若要测试请求响应 Web 服务,请单击 Web 服务仪表板中的“测试”按钮。To test the Request Response web service, click the Test button in the web service dashboard. 将弹出一个对话框,要求输入服务的输入数据。A dialog pops up to ask you for the input data for the service. 下面是评分实验预期的列。These are the columns expected by the scoring experiment. 输入一组数据,并单击“确定”。Enter a set of data and then click OK. Web 服务生成的结果显示在仪表板的底部。The results generated by the web service are displayed at the bottom of the dashboard.

可以单击“测试”预览链接,在 Azure 机器学习工作室(经典)Web 服务门户中测试服务,如“新建 Web 服务”部分中所示。You can click the Test preview link to test your service in the Azure Machine Learning Studio (classic) Web Services portal as shown previously in the New web service section.

若要测试 Batch 执行服务,请单击“测试”预览链接。To test the Batch Execution Service, click Test preview link . 在 Batch 测试页上,单击输入下的“浏览”,并选择包含相应示例值的 CSV 文件。On the Batch test page, click Browse under your input and select a CSV file containing appropriate sample values. 如果没有 CSV 文件,并且已使用机器学习工作室(经典)创建了预测试验,则可以下载预测试验的数据集并使用它。If you don't have a CSV file, and you created your predictive experiment using Machine Learning Studio (classic), you can download the data set for your predictive experiment and use it.

测试 Web 服务

在“配置”页上,可以更改服务的显示名称并提供说明。On the CONFIGURATION page, you can change the display name of the service and give it a description. 名称和说明会显示在 Azure 门户中,可以在其中管理 Web 服务。The name and description is displayed in the Azure portal where you manage your web services.

可通过在输入架构输出架构Web 服务参数下为每列输入字符串来为输入数据、输出数据和 Web 服务参数提供描述。You can provide a description for your input data, output data, and web service parameters by entering a string for each column under INPUT SCHEMA, OUTPUT SCHEMA, and Web SERVICE PARAMETER. 这些描述用于为 Web 服务提供的示例代码文档中。These descriptions are used in the sample code documentation provided for the web service.

可启用日志记录来诊断在访问 Web 服务时遇到的任何故障。You can enable logging to diagnose any failures that you're seeing when your web service is accessed. 有关详细信息,请参阅为机器学习工作室(经典)Web 服务启用日志记录For more information, see Enable logging for Machine Learning Studio (classic) web services.

在 Web 服务门户中启用日志记录

还可在 Azure 机器学习 Web 服务门户中配置 Web 服务的终结点,类似于之前在“新建 Web 服务”部分中显示的过程。You can also configure the endpoints for the web service in the Azure Machine Learning Web Services portal similar to the procedure shown previously in the New web service section. 选项有所不同,可以添加或更改服务描述、启用日志记录,并启用样本数据进行测试。The options are different, you can add or change the service description, enable logging, and enable sample data for testing.

访问经典 Web 服务Access your Classic web service

从 Azure 机器学习工作室(经典)部署 Web 服务后,可以采用编程方式向服务发送数据并接收响应。Once you deploy your web service from Azure Machine Learning Studio (classic), you can send data to the service and receive responses programmatically.

仪表板提供访问 Web 服务所需的所有信息。The dashboard provides all the information you need to access your web service. 例如,提供 API 密钥以允许对服务的授权访问,并提供 API 帮助页以帮助你开始编写代码。For example, the API key is provided to allow authorized access to the service, and API help pages are provided to help you get started writing your code.

有关访问机器学习工作室(经典)Web 服务的详细信息,请参阅如何使用 Azure 机器学习工作室(经典)Web 服务For more information about accessing a Machine Learning Studio (classic) web service, see How to consume an Azure Machine Learning Studio (classic) Web service.

管理经典 Web 服务Manage your Classic web service

可通过执行各种操作来监视 Web 服务。There are various of actions you can perform to monitor a web service. 可以将其更新,也可以将其删除。You can update it, and delete it. 除了部署经典 Web 服务时创建的默认终结点外,还可向其添加其他终结点。You can also add additional endpoints to a Classic web service in addition to the default endpoint that is created when you deploy it.

有关详细信息,请参阅管理 Azure 机器学习工作室(经典)工作区使用 Azure 机器学习工作室(经典)Web 服务门户管理 Web 服务For more information, see Manage an Azure Machine Learning Studio (classic) workspace and Manage a web service using the Azure Machine Learning Studio (classic) Web Services portal.

更新 Web 服务Update the web service

可更改 Web 服务,例如使用其他训练数据更新模型、重新部署、覆盖原始 Web 服务等。You can make changes to your web service, such as updating the model with additional training data, and deploy it again, overwriting the original web service.

要更新 Web 服务,请打开用于部署 Web 服务的原始预测实验,并单击“另存为”以创建可编辑的副本。To update the web service, open the original predictive experiment you used to deploy the web service and make an editable copy by clicking SAVE AS. 进行更改,并单击“部署 Web 服务”。Make your changes and then click Deploy Web Service.

由于之前已部署此实验,系统会询问是要覆盖(经典 Web 服务)还是更新(新 Web 服务)现有服务。Because you've deployed this experiment before, you are asked if you want to overwrite (Classic Web Service) or update (New web service) the existing service. 单击“是”或“更新”将停止现有 Web 服务并部署新预测实验。Clicking YES or Update stops the existing web service and deploys the new predictive experiment is deployed in its place.

备注

如果在原始 Web 服务中进行了配置更改,例如输入新的显示名称或描述,则需要重新输入这些值。If you made configuration changes in the original web service, for example, entering a new display name or description, you will need to enter those values again.

更新 Web 服务的一种方法是以编程方式重新训练模型。One option for updating your web service is to retrain the model programmatically. 有关详细信息,请参阅以编程方式重新训练机器学习工作室(经典)模型For more information, see Retrain Machine Learning Studio (classic) models programmatically.

后续步骤Next steps