azure机器学习_如何在Azure机器学习中使用JSON数据

azure机器学习

Azure Machine Learning (also known as Azure ML) is cloud-based machine learning solution of Microsoft. Microsoft Azure Machine Learning is a fully-managed cloud-based service that provides the ability to create and train predictive analytic solutions. Another advantage of Azure ML is that you can access and easily make changes anywhere in machine learning models with help of Microsoft Azure Machine Learning Studio.

Azure机器学习(也称为Azure ML)是Microsoft的基于云的机器学习解决方案。 Microsoft Azure机器学习是一项完全托管的基于云的服务,可提供创建和训练预测分析解决方案的功能。 Azure ML的另一个优点是,您可以借助Microsoft Azure Machine Learning Studio在机器学习模型中的任何地方访问并轻松进行更改。

We can sign into Azure Machine Learning Studio in a web browser and create, change and train machine learning experiments. Also, we can convert these training experiments to predictive experiment and publish it as a web service. In my opinion, the major feature of Azure ML Studio is drag-and-drop because this option allows us to create and connect analyze modules very easily. In addition, drag-and-drop provides the benefit to write very few code. Another key feature of Azure ML is R module support.

我们可以在Web浏览器中登录Azure Machine Learning Studio并创建,更改和训练机器学习实验。 另外,我们可以将这些训练实验转换为预测性实验,并将其发布为Web服务。 我认为,Azure ML Studio的主要功能是拖放功能,因为此选项使我们可以非常轻松地创建和连接分析模块。 此外,拖放操作的好处是只需编写很少的代码。 Azure ML的另一个关键功能是R模块支持。

According to Microsoft documentation; Azure ML supports more than 400 R packages. This means that Azure ML allows us to use tons of R function collections. At the same time this feature increases the power of Azure ML. If we make a short list of the main advantages of Azure ML;

根据Microsoft的文档; Azure ML支持400多个R程序包 。 这意味着Azure ML允许我们使用大量R函数集合。 同时,此功能增强了Azure ML的功能。 如果我们简短列出Azure ML的主要优点;

  • A fully-managed cloud-based service

    全面管理的基于云的服务
  • Interactive and easy access workspace of Microsoft Azure Machine Learning Studio

    Microsoft Azure Machine Learning Studio的交互式且易于访问的工作区
  • R and Python support

    R和Python支持
  • Easy deployment and usage with web service support

    通过Web服务支持轻松部署和使用

After this brief information about Azure ML, we can focus on the main idea of this article. In this article, we will explore how to use JSON data in an Azure ML experiment as a dataset. Data is an indispensable part of machine learning experiments. The main and essential inputs of machine learning experiments are data because the selected algorithm of the experiment will process and create output with help of this dataset. On the other hand, JSON is the most popular key-value pair data interchange format and great number of applications use this data interchange format.

在获得有关Azure ML的简短信息之后,我们可以集中讨论本文的主要思想。 在本文中,我们将探讨如何在Azure ML实验中将JSON数据用作数据集。 数据是机器学习实验中必不可少的部分。 机器学习实验的主要和必要输入是数据,因为实验的所选算法将在此数据集的帮助下进行处理并创建输出。 另一方面,JSON是最流行的键值对数据交换格式,并且许多应用程序都使用这种数据交换格式。

In this article (How to use JSON data in SSRS) you can find detail information about JSON and JSON data structure.

在本文( 如何在SSRS中使用JSON数据 )中,您可以找到有关JSON和JSON数据结构的详细信息。

如何将数据导入Azure ML? (How to import data to Azure ML?)

The Import data module is the main module to load data from external sources for Azure but there is a lack of an import data module that supports JSON. The Import data module supports the following data sources but this list does not include any provider for JSON data.

导入数据模块是从Azure的外部源加载数据的主要模块,但是缺少支持JSON的导入数据模块。 导入数据模块支持以下数据源,但此列表不包括JSON数据的任何提供程序。

  • Web URL via HTTP

    通过HTTP的Web URL
  • Hive Query

    蜂巢查询
  • Azure SQL Database

    Azure SQL数据库
  • Azure Table

    Azure表
  • Import from Azure Blob Storage

    从Azure Blob存储导入
  • Data Feed Providers

    数据提要提供者
  • Import from On-Premises SQL Server Database

    从本地SQL Server数据库导入
  • Azure Cosmos DB

    Azure Cosmos数据库

Microsoft recommends that if we need to import data from JSON we can use Execute Python Script or Execute R Script modules. In this article, we will use Execute R Script module. In the following demonstrations, we will use Execute R Script module. This module is used to execute R script codes in Azure ML Studio.

Microsoft建议,如果需要从JSON导入数据,则可以使用“执行Python脚本”或“执行R脚本”模块。 在本文中,我们将使用Execute R Script模块。 在以下演示中,我们将使用Execute R Script模块。 此模块用于在Azure ML Studio中执行R脚本代码。

The Execute R Script module has three input parameters. These are Dataset1, Dataset2 and Script Bundle. With help of Dataset1 and Dataset2 inputs you can import data to Execute R Script module. The Script Bundle port can take a zip file and this zip file can contain several file types. In our demonstration, we will use this Script Bundle port to load JSON.

Execute R Script模块具有三个输入参数。 它们是Dataset1,Dataset2和脚本包。 借助Dataset1和Dataset2输入,您可以将数据导入Execute R Script模块。 脚本捆绑包端口可以获取一个zip文件,并且该zip文件可以包含多种文件类型。 在我们的演示中,我们将使用此脚本包端口加载JSON。

In the right side of screen, you can find R Script text box. The R script text box helps us to write and execute R script codes.

在屏幕右侧,您可以找到R脚本文本框。 R脚本文本框可帮助我们编写和执行R脚本代码。

如何在Azure Machine Learning中上载和使用JSON文件作为数据集 (How to upload and use a JSON file as a dataset in Azure Machine Learning)

In this part, we will demonstrate how to import a zipped JSON file to Azure ML. Imagine that we have a JSON data file and we want to use this JSON file as a dataset for Azure ML. You can download the sample JSON data in JSONPlaceholder and then you have to zip this JSON file.

在这一部分中,我们将演示如何将压缩的JSON文件导入Azure ML。 假设我们有一个JSON数据文件,并且希望将此JSON文件用作Azure ML的数据集。 您可以在JSONPlaceholder中下载示例JSON数据,然后必须压缩该JSON文件。

Select Dataset tab in Azure ML Studio and click (+) New

在Azure ML Studio中选择``数据集''选项卡,然后单击(+)新建

Select FROM LOCAL FILE

从本地文件中选择

Select the path of zipped JSON file and chose the SELECT A TYPE FOR THE NEW DATASET as a Zip File

选择压缩的JSON文件的路径,然后选择“ 选择新数据集的类型”作为Zip文件

Click the check icon

点击检查图标

After the successful uploading process, you will get the Upload of the dataset ‘SampeJSONData.zip’ has completed notification and SampleJSONData file shows in the MY DATASETS tab.

成功完成上传过程后,您将获得数据集“ SampeJSONData.zip”上传已完成通知,并且SampleJSONData文件显示在MY DATASETS选项卡中。

Select Experiments tab and click (+) NEW.

选择实验标签,然后点击(+)新建。

Chose the Blank Experiment option and then create a new experiment.

选择空白实验选项,然后创建一个新实验。

Find SampleJSONData.zip then drag and drop SampleJSONData.zip to design panel.

找到SampleJSONData.zip,然后将SampleJSONData.zip拖放到设计面板中。

Drag and drop Execute R Script Module.

拖放执行R脚本模块。

Connect the SampeJSONData.zip output to Execute R Script Module Script Bundle port.

将SampeJSONData.zip输出连接到Execute R Script Module Script Bundle端口。

Paste the following R script code to the R script textbox.

将以下R脚本代码粘贴到R脚本文本框中。

library(jsonlite)
myjsondata <-  fromJSON("src/posts.txt")
maml.mapOutputPort("myjsondata");



Now, we will explain the above R script code line by line.

现在,我们将逐行解释上面的R脚本代码。

library(jsonlite) : This code part allows us to use Jsonlite package of R

library(jsonlite) :此代码部分使我们可以使用R的Jsonlite包

myjsondata <- fromJSON(“src/posts.txt”): In this part of code we load posts.txt json file and assign the output of this process to myjsondata variable. The “src/posts.txt” part defines our zipped file name.

myjsondata <-fromJSON(“ src / posts.txt”) :在这部分代码中,我们加载posts.txt json文件,并将此过程的输出分配给myjsondata变量。 “ src / posts.txt”部分定义了我们的压缩文件名。

maml.mapOutputPort(“myjsondata”) : In this code, line is sent to myjsondata variable result to output Result Dataset port of Execute R Script Module.

maml.mapOutputPort(“ myjsondata”) :在此代码中,将行发送到myjsondata变量result,以输出Execute R脚本模块的Result Dataset端口。

Run the experiment then right click Result Dataset port of Execute R Script module and select Visualize

运行实验,然后右键单击Execute R Script模块的Result Dataset端口,然后选择Visualize

Finally, we got the JSON data from zip file and converted it to usable format in Azure ML experiments. Now, we can get JSON data from any web site.

最后,我们从zip文件中获取JSON数据,并将其转换为Azure ML实验中可用的格式。 现在,我们可以从任何网站获取JSON数据。

如何在Azure Machine Learning中从网站获取JSON数据? (How to get JSON data from a web site in Azure Machine Learning?)

Actually, this option is very similar to the previous demonstration. In this option, we only change the source of JSON data file. In the previous demonstration, we used to have a zip file but, in this demonstration, we will use JSON data on website.

实际上,此选项与先前的演示非常相似。 在此选项中,我们仅更改JSON数据文件的源。 在前面的演示中,我们曾经有一个zip文件,但是在此演示中,我们将在网站上使用JSON数据。

Modify the R script module code which like the following.

修改R脚本模块代码,如下所示。

library(jsonlite)
myjsondata <-  fromJSON("https://jsonplaceholder.typicode.com/posts ")
maml.mapOutputPort("myjsondata");

Run the experiment.

运行实验。

When you visualize the Result Dataset of R script module you can see it getting the JSONPlaceholder posts JSON data.

当可视化R脚本模块的Result数据集时,您可以看到它使JSONPlaceholder发布JSON数据。

In the below image we can see the compare of JSON form and visualization form.

在下图中,我们可以看到JSON形式与可视化形式的比较。

结论 (Conclusion)

In this article, we learned detail usage of JSON data in Azure Machine Learning. The main idea of this solution is based on R support of Azure Machine Learning. Azure Machine Learning is definitely bringing it’s A-game with R and Python support.

在本文中,我们学习了Azure机器学习中JSON数据的详细用法。 此解决方案的主要思想基于Azure机器学习的R支持。 Azure机器学习肯定会带来具有R和Python支持的A游戏。

翻译自: https://www.sqlshack.com/how-to-use-json-data-in-azure-machine-learning/

azure机器学习

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值