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

什么是 Azure HDInsight 中的 ML 服务What is ML Services in Azure HDInsight

可以在 Azure 中创建 HDInsight 群集时选择使用 Microsoft Machine Learning Server 部署。Microsoft Machine Learning Server is available as a deployment option when you create HDInsight clusters in Azure. 提供此选项的群集类型名为 ML Services 。The cluster type that provides this option is called ML Services . 使用此功能可以按需访问 HDInsight 上的自适应分布式分析方法。This capability provides on-demand access to adaptable, distributed methods of analytics on HDInsight.

HDInsight 上的 ML 服务提供最新的功能,以用于针对几乎任何大小的数据集执行基于 R 的分析。ML Services on HDInsight provides the latest capabilities for R-based analytics on datasets of virtually any size. 可将数据集加载到 Azure Blob 或 Data Lake Storage。The datasets can be loaded to either Azure Blob or Data Lake storage. 基于 R 的应用程序可以使用 8000 多个开源 R 包。Your R-based applications can use the 8000+ open-source R packages. ScaleR 中的例程(Microsoft 的大数据分析包)同样可用。The routines in ScaleR, Microsoft's big data analytics package are also available.

边缘节点为连接到群集和运行 R 脚本提供了便捷的位置。The edge node provides a convenient place to connect to the cluster and run your R scripts. 边缘节点允许跨服务器的核心运行 ScaleR 并行化分布式函数。The edge node allows running the ScaleR parallelized distributed functions across the cores of the server. 还可以通过使用 ScaleR 的 Hadoop Map Reduce 跨群集的各个节点运行这些函数。You can also run them across the nodes of the cluster by using ScaleR's Hadoop Map Reduce. 此外,还可以使用 Apache Spark 计算上下文。You can also use Apache Spark compute contexts.

可以下载分析后生成的模型或预测,以便在本地使用。The models or predictions that result from analysis can be downloaded for on-premises use. 也可在 Azure 中的其他位置对其进行operationalizedThey can also be operationalized elsewhere in Azure. 具体而言,可以通过 Azure 机器学习工作室(经典版)Web 服务将其操作化。In particular, through Azure Machine Learning Studio (classic), and web service.

HDInsight 上的 ML Services 入门Get started with ML Services on HDInsight

若要在 HDInsight 中创建 ML 服务群集,请选择“ML 服务”群集类型。 To create an ML Services cluster in HDInsight, select the ML Services cluster type. ML 服务群集类型包括数据节点上的 ML Server,以及边缘节点。The ML Services cluster type includes ML Server on the data nodes, and edge node. 边缘节点充当基于 ML 服务的分析的登陆区域。The edge node serves as a landing zone for ML Services-based analytics. 有关如何创建群集的演练,请参阅使用 Azure 门户创建 Apache Hadoop 群集See Create Apache Hadoop clusters using the Azure portal for a walkthrough on how to create the cluster.

为什么选择 HDInsight 中的 ML Services?Why choose ML Services in HDInsight?

HDInsight 中的 ML Services 具有下述优势:ML Services in HDInsight provides the following benefits:

通过 Microsoft 和开放源代码获得 AI 创新AI innovation from Microsoft and open-source

ML 服务包含高度自适应性的分布式算法集,例如 RevoscaleRrevoscalepymicrosoftMLML Services includes highly adaptable, distributed set of algorithms such as RevoscaleR, revoscalepy, and microsoftML. 这些算法可以处理超出物理内存大小的数据。These algorithms can work on data sizes larger than the size of physical memory. 它们还能以分散的方式在各种平台上运行。They also run on a wide variety of platforms in a distributed manner. 详细了解产品随附的 Microsoft 自定义 R 包Python 包集合。Learn more about the collection of Microsoft's custom R packages and Python packages included with the product.

ML 服务将这些 Microsoft 创新和来自开源社区的贡献(R、Python 和 AI 工具包)联系在一起。ML Services bridges these Microsoft innovations and contributions coming from the open-source community (R, Python, and AI toolkits). 所有这些都在单个企业级平台上。All on top of a single enterprise-grade platform. 任何 R 或 Python 开放源代码机器学习包都可与来自 Microsoft 的任何专属创新配合运行。Any R or Python open-source machine learning package can work side by side with any proprietary innovation from Microsoft.

简单、安全且高度可缩放的操作和管理Simple, secure, and high-scale operationalization and administration

依赖于传统模式和环境的企业在操作化方面投入了许多时间和精力。Enterprises relying on traditional paradigms and environments invest much time and effort towards operationalization. 此措施会导致成本和延迟增大,因为这涉及到模型转换时间、让它们保持有效及最新状态的迭代工作、法规审批,以及管理权限。This action results in inflated costs and delays including the translation time for: models, iterations to keep them valid and current, regulatory approval, and managing permissions.

ML 服务提供企业级操作化ML Services offers enterprise grade operationalization. 在完成机器学习模型后,只需单击几下鼠标就能生成 Web 服务 API。After a machine learning model completes, it takes just a few clicks to generate web services APIs. 这些 Web 服务托管在服务器网格或云中,并且可与业务线应用程序集成。These web services are hosted on a server grid in the cloud and can be integrated with line-of-business applications. 部署到弹性网格的能力可让你根据业务需求,针对批处理和实时评分无缝缩放。The ability to deploy to an elastic grid lets you scale seamlessly with the needs of your business, both for batch and real-time scoring. 有关说明,请参阅使 HDInsight 上的 ML Services 可操作For instructions, see Operationalize ML Services on HDInsight.

备注

HDInsight 上的 ML Services 群集类型仅在 HDInsight 3.6 上受支持。The ML Services cluster type on HDInsight is supported only on HDInsight 3.6. HDInsight 3.6 计划于 2020 年 12 月 31 日停用。HDInsight 3.6 is scheduled to retire on December 31, 2020.

HDInsight 上的 ML Services 的主要功能Key features of ML Services on HDInsight

HDInsight 上的 ML Services 包含以下功能。The following features are included in ML Services on HDInsight.

功能类别Feature category 说明Description
支持 RR-enabled 适用于以 R 编写的解决方案的 R 包,其中包含 R 的开源分发版和用于执行脚本的运行时基础结构。R packages for solutions written in R, with an open-source distribution of R, and run-time infrastructure for script execution.
支持 PythonPython-enabled 适用于以 Python 编写的解决方案的 Python 模块,其中包含 Python 的开源分发版和用于执行脚本的运行时基础结构。Python modules for solutions written in Python, with an open-source distribution of Python, and run-time infrastructure for script execution.
预先训练的模型Pre-trained models 适用于可视化分析和文本情绪分析,随时可用于对提供的数据进行评分。For visual analysis and text sentiment analysis, ready to score data you provide.
部署和使用Deploy and consume Operationalize你的服务器,将解决方案部署为 Web 服务。Operationalize your server and deploy solutions as a web service.
远程执行Remote execution 在客户端工作站中,通过网络在 ML Services 群集 上启动远程会话。Start remote sessions on ML Services cluster on your network from your client workstation.

适用于 HDInsight 上的 ML Services 的数据存储选项Data storage options for ML Services on HDInsight

HDFS 文件系统的默认存储可以是 Azure 存储帐户或 Azure Data Lake Storage。Default storage for the HDFS file system can be an Azure Storage account or Azure Data Lake Storage. 在分析期间上传到群集存储的数据会持久保存。Uploaded data to cluster storage during analysis is made persistent. 即使在删除群集后,该数据也可供使用。The data is available even after the cluster is deleted. 有多种工具可以处理将数据传输到存储。Various tools can handle the data transfer to storage. 这些工具包括存储帐户的基于门户的上传工具和 AzCopy 实用工具。The tools include the portal-based upload facility of the storage account and the AzCopy utility.

可以在创建群集期间启用对附加 Blob 和 Data Lake Store 的访问。You can enable access to additional Blob and Data lake stores during cluster creation. 此功能不受限于使用的主存储选项。You aren't limited by the primary storage option in use. 要了解有关使用多个存储帐户的详细信息,请参阅适用于 HDInsight 上的 ML Services 的 Azure 存储选项一文。See Azure Storage options for ML Services on HDInsight article to learn more about using multiple storage accounts.

也可以将 Azure 文件存储用作边缘节点上的存储选项。You can also use Azure Files as a storage option for use on the edge node. 使用 Azure 文件存储可以在 Linux 文件系统中启用 Azure 存储中创建的文件共享。Azure Files enables file shares created in Azure Storage to the Linux file system. 有关详细信息,请参阅适用于 HDInsight 上的 ML 服务的 Azure 存储选项For more information, see Azure Storage options for ML Services on HDInsight.

访问 ML Services 边缘节点Access ML Services edge node

可以使用浏览器或 SSH/PuTTY 连接到边缘节点上的 Microsoft ML Server。You can connect to Microsoft ML Server on the edge node using a browser, or SSH/PuTTY. 在创建群集期间,默认会安装 R 控制台。The R console is installed by default during cluster creation.

开发和运行 R 脚本Develop and run R scripts

R 脚本可以使用 8000 多个开源 R 包中的任何一个。Your R scripts can use any of the 8000+ open-source R packages. 你还可以使用 ScaleR 库中的并行化分布式例程。You can also use the parallelized and distributed routines from the ScaleR library. 在边缘节点上运行的脚本将在该节点上的 R 解释器中运行。Scripts run on the edge node run within the R interpreter on that node. 但是,使用 Map Reduce (RxHadoopMR) 或 Spark (RxSpark) 计算上下文调用 ScaleR 函数的步骤除外。Except for steps that call ScaleR functions with a Map Reduce (RxHadoopMR) or Spark (RxSpark) compute context. 这些函数将以分散的方式在与数据关联的各个数据节点上运行。The functions run in a distributed fashion across the data nodes that are associated with the data. 有关上下文选项的详细信息,请参阅适用于 HDInsight 上的 ML 服务的计算上下文选项For more information about context options, see Compute context options for ML Services on HDInsight.

Operationalize模型Operationalize a model

完成数据建模后,可以在 Azure 中或本地operationalize模型,以便针对新数据执行预测。When your data modeling is complete, operationalize the model to make predictions for new data either from Azure or on-premises. 此过程称为评分。This process is known as scoring. 可以在 HDInsight、Azure 机器学习或本地进行评分。Scoring can be done in HDInsight, Azure Machine Learning, or on-premises.

在 HDInsight 中评分Score in HDInsight

若要在 HDInsight 中评分,请编写一个 R 函数。To score in HDInsight, write an R function. 该函数会调用你的模型,以针对加载到存储帐户中的新数据文件做出预测。The function calls your model to make predictions for a new data file that you've loaded to your storage account. 然后将预测保存回到存储帐户。Then, save the predictions back to the storage account. 可以根据需要在群集的边缘节点上运行该例程,或使用计划作业来进行。You can run this routine on-demand on the edge node of your cluster or by using a scheduled job.

在 Azure 机器学习中评分 (AML)Score in Azure Machine Learning (AML)

若要使用 Azure 机器学习进行评分,请使用名为 AzureML 的开放源代码 Azure 机器学习 R 包将模型发布为 Azure Web 服务。To score using Azure Machine Learning, use the open-source Azure Machine Learning R package known as AzureML to publish your model as an Azure web service. 为提供方便,此包已预装在边缘节点上。For convenience, this package is pre-installed on the edge node. 接下来,使用 Azure 机器学习中的工具创建 Web 服务的用户界面,并根据需要调用 Web 服务进行评分。Next, use the facilities in Azure Machine Learning to create a user interface for the web service, and then call the web service as needed for scoring. 然后,将 ScaleR 模型对象转换成等效的开源模型对象以用于 Web 服务。Then convert ScaleR model objects to equivalent open-source model objects for use with the web service. 使用 ScaleR 强制转换函数,例如适用于装配模型的 as.randomForest() 来完成转换。Use ScaleR coercion functions, such as as.randomForest() for ensemble-based models, for this conversion.

本地评分Score on-premises

若要在创建模型后进行本地评分,请使用 R 来序列化模型,将其下载,将其反序列化,然后使用它来为新数据评分。To score on-premises after creating your model: serialize the model in R, download it, de-serialize it, then use it for scoring new data. 可以使用前面“在 HDInsight 中评分”中所述的方法,或使用 Web 服务对新数据进行评分。You can score new data by using the approach described earlier in Score in HDInsight or by using web services.

维护群集Maintain the cluster

安装和维护 R 包Install and maintain R packages

由于 R 脚本的大多数步骤在边缘节点上运行,因此边缘节点上需要有大部分使用的 R 包。Most of the R packages that you use are required on the edge node since most steps of your R scripts run there. 若要在边缘节点上安装其他 R 包,可以在 R 中使用 install.packages() 方法。To install additional R packages on the edge node, you can use the install.packages() method in R.

如果只是使用 ScaleR 库例程,则通常不需要附加的 R 包。If you're just using ScaleR library routines, you don't usually need additional R packages. 可能需要对数据节点上的 rxExec 或 RxDataStep 执行使用附加的包。 You might need additional packages for rxExec or RxDataStep execution on the data nodes.

可以在创建群集之后,使用脚本操作来安装附加的包。The additional packages can be installed with a script action after you create the cluster. 有关详细信息,请参阅管理 HDInsight 群集中的 ML ServicesFor more information, see Manage ML Services in HDInsight cluster.

更改 Apache Hadoop MapReduce 内存设置Change Apache Hadoop MapReduce memory settings

可以在 ML 服务运行 MapReduce 作业时修改其可用内存。Available memory to ML Services can be modified when it's running a MapReduce job. 若要修改群集,请对群集使用 Apache Ambari UI。To modify a cluster, use the Apache Ambari UI for your cluster. 有关 Ambari UI 的说明,请参阅使用 Ambari Web UI 管理 HDInsight 群集For Ambari UI instructions, see Manage HDInsight clusters using the Ambari Web UI.

可以在 RxHadoopMR 调用中使用 Hadoop 开关更改 ML 服务的可用内存: Available memory to ML Services can be changed by using Hadoop switches in the call to RxHadoopMR :

hadoopSwitches = "-libjars /etc/hadoop/conf -Dmapred.job.map.memory.mb=6656"

缩放群集Scale your cluster

可以通过门户扩展或缩减现有的 HDInsight 上的 ML Services 群集。An existing ML Services cluster on HDInsight can be scaled up or down through the portal. 通过纵向扩展,可以获得更多的容量来完成更大的处理任务。By scaling up, you gain additional capacity for larger processing tasks. 可以在群集空闲时缩减其容量。You can scale back a cluster when it's idle. 有关如何缩放群集的说明,请参阅管理 HDInsight 群集For instructions about how to scale a cluster, see Manage HDInsight clusters.

维护系统Maintain the system

在非工作时间,系统将在 HDInsight 群集中的基础 Linux VM 上执行 OS 维护。OS Maintenance is done on the underlying Linux VMs in an HDInsight cluster during off-hours. 通常,维护工作是在每个星期一和星期四的凌晨 3:30(VM 本地时间)执行的。Typically, maintenance is done at 3:30 AM (VM's local time) every Monday and Thursday. 每次更新不会影响超过四分之一的群集。Updates don't impact more than a quarter of the cluster at a time.

在维护期间,正在运行的作业可能会变慢。Running jobs might slow down during maintenance. 但是,这些作业应该都可运行完成。However, they should still run to completion. 除非发生需要重建群集的灾难性故障,否则任何自定义软件或本地数据在这些维护事件中都将保留。Any custom software or local data that you've is preserved across these maintenance events unless a catastrophic failure occurs that requires a cluster rebuild.

适用于 HDInsight 上的 ML Services 的 IDE 选项IDE options for ML Services on HDInsight

HDInsight 群集的 Linux 边缘节点是基于 R 的分析的登录区域。The Linux edge node of an HDInsight cluster is the landing zone for R-based analysis. 最新版本的 HDInsight 在边缘节点上提供 RStudio Server 的基于浏览器的 IDE。Recent versions of HDInsight provide a browser-based IDE of RStudio Server on the edge node. 对于开发和执行而言,RStudio Server 的工作效率高于 R 控制台。RStudio Server is more productive than the R console for development and execution.

桌面 IDE 可以通过远程 MapReduce 或 Spark 计算上下文访问群集。A desktop IDE can access the cluster through a remote MapReduce or Spark compute context. 选项包括:Microsoft 的针对 Visual Studio 的 R 工具 (RTVS)、RStudio,以及 Walware 的基于 Eclipse 的 StatET。Options include: Microsoft's R Tools for Visual Studio (RTVS), RStudio, and Walware's Eclipse-based StatET.

通过在命令提示符下键入 R 来访问边缘节点上的 R 控制台。 Access the R console on the edge node by typing R at the command prompt. 使用控制台界面时,可以方便地在文本编辑器中开发 R 脚本。When using the console interface, it's convenient to develop R script in a text editor. 然后,根据需要将脚本的部分剪切并粘贴到 R 控制台。Then cut and paste sections of your script into the R console as needed.

定价Pricing

ML 服务 HDInsight 群集相关价格的构成类似于其他 HDInsight 群集类型。The prices associated with an ML Services HDInsight cluster are structured similarly to other HDInsight cluster types. 这些价格基于采用各种名称、数据和边缘节点的基础 VM 的大小。They're based on the sizing of the underlying VMs across the name, data, and edge nodes. 此外还会加上核心运行小时数附加费。Core-hour uplifts as well. 有关详细信息,请参阅 HDInsight 定价For more information, see HDInsight pricing.

后续步骤Next steps

若要详细了解如何在 HDInsight 群集上使用 ML 服务,请参阅以下文章:To learn more about how to use ML Services on HDInsight clusters, see the following articles: