azure机器学习

Good, clean and reliable data is important for every company, because well-analyzed data will open new possibilities to success. When we look at successful companies, we see that they’ve analyzed customers, sales, and finance data very well. At this point, a game changer enters: machine learning.

良好,整洁和可靠的数据对每个公司都至关重要,因为经过充分分析的数据将为成功打开新的可能性。 当我们查看成功的公司时,我们发现他们已经很好地分析了客户,销售和财务数据。 在这一点上,游戏规则改变者进入:机器学习。

机器学习 (Machine learning)

Machine learning is a type of artificial intelligence which analyzes data in order to predict future and discover hidden patterns. The output helps us make decisions. Machine learning is widely used in finance, healthcare and marketing.

机器学习是一种人工智能,它分析数据以预测未来并发现隐藏的模式。 输出有助于我们做出决定。 机器学习广泛用于金融,医疗保健和市场营销。

Machine learning …

机器学习…

  • Develops itself by continuous learning 通过不断学习来发展
  • Provides a forecast for the future 提供对未来的预测
  • Finds out hidden patterns in data 找出数据中的隐藏模式
  • Supports more effective algorithms than traditional algorithms 支持比传统算法更有效的算法

Azure机器学习 (Azure Machine Learning)

Azure Machine Learning aka Azure ML is a cloud-based computer driven learning environment developed by Microsoft. Azure Machine Learning helps us to make decisions by analyzing data and using it to predict future patterns and outcomes. Suppose you have sales data and you want to make some decisions, for next year, based on it. You don’t need experienced employees, advanced algorithms or large-capacity computers. Azure Machine Learning allows making these calculations on the cloud.

Azure机器学习又名Azure ML是由Microsoft开发的基于云的计算机驱动的学习环境。 Azure机器学习通过分析数据并使用其预测未来的模式和结果来帮助我们做出决策。 假设您有销售数据,并且希望根据该数据为明年做出一些决策。 您不需要经验丰富的员工,高级算法或大容量计算机。 Azure机器学习允许在云上进行这些计算。

In this article we will integrate Microsoft SQL Server and Azure Machine Learning. So we will have artificial intelligence code on the SQL Server Engine which machine learning model created by us. This code can be used in Power BI, SQL Server Reporting Service or SQL Server Mobile Reports. With this integration, SQL Server gains machine learning ability.

在本文中,我们将集成Microsoft SQL Server和Azure机器学习。 因此,我们将在SQL Server Engine上拥有由我们创建的机器学习模型的人工智能代码。 此代码可以在Power BI,SQL Server报告服务或SQL Server移动报告中使用。 通过这种集成,SQL Server获得了机器学习能力。

Shortly, in this article we will:

不久,在本文中,我们将:

  • Create an Azure Machine Learning experiment on Azure Machine Learning Studio 在Azure Machine Learning Studio上创建Azure Machine Learning实验
  • Publish an Azure Machine Learning model on web service 在Web服务上发布Azure机器学习模型
  • Enable a SQL Server external script 启用S​​QL Server外部脚本
  • Call this service from SQL Server with R script support 从具有R脚本支持SQL Server调用此服务

我们的第一个Azure机器学习实验 (Our first Azure Machine Learning experiment)

In this experiment we will create a linear regression model on Azure ML. Linear regression is the most widely known algorithm. In first step we will login into Azure Machine Learning Studio and create a blank experiment.

在本实验中,我们将在Azure ML上创建线性回归模型。 线性回归是最广为人知的算法。 第一步,我们将登录到Azure Machine Learning Studio并创建一个空白实验。

We will add sample dataset which name is “Energy Efficiency Regression Data” and then add “Select Columns in Dataset” component. This sample dataset contains cooling data and the conditions which these values ​​are generated. Such as surface area, wall area etc.

我们将添加示例数据集,其名称为“能效回归数据”,然后添加“选择数据集中的列”组件。 该样本数据集包含冷却数据以及生成这些值的条件。 如表面积,壁面积等

We will select columns for the machine learning model. These columns are “Surface Area”, “Wall Area”, ”Roof Area” and “Cooling Load”. Based on our theoretical company, these are variables that are used to determine the load and costs of cooling for our building structures.

我们将为机器学习模型选择列。 这些列是“表面面积”,“墙壁面积”,“屋顶面积”和“制冷负荷”。 根据我们的理论公司,这些变量用于确定建筑结构的冷却负荷和成本。

We will use the first three variables: “Surface Area”, “Wall Area”, “Roof Area” to predict the “Cooling Load”

我们将使用前三个变量:“表面面积”,“墙面面积”,“屋顶面积”来预测“冷却负荷”

We will add “Split Data” component. This component allows us to divide dataset into training data ((training data is used as part of the machine learning process to build the model that will produce our results) and test data (test data is used to evaluate output of algorithm). We will set “Fraction of rows in the first output dataset” to 0.8. This value defines that 80% of data will be used for training and 20% of data for testing.

我们将添加“拆分数据”组件。 该组件使我们可以将数据集分为训练数据((训练数据用作机器学习过程的一部分,以构建将产生结果的模型)和测试数据(用于测试算法输出的测试数据)。将“第一个输出数据集中的行分数”设置为0.8,该值定义80%的数据将用于训练,而20%的数据将用于测试。

In this step, we will now create our machine learning model. We will add “Linear Regression” component and the “Train Model” component. The Linear regression component will create our algorithm and the train model component includes which column we will predict, which will be “Cooling Load”.

在这一步中,我们现在将创建我们的机器学习模型。 我们将添加“线性回归”组件和“火车模型”组件。 线性回归组件将创建我们的算法,火车模型组件将包含我们将预测的列,即“冷却负荷”。

We will add “Score Model” and “Evaluate Model”. These components help us to evaluate our machine learning model. Some values ​​in these components indicate the accuracy of model. Each algorithm will not be suitable for each data set. For this reason, we will evaluate our model results. The Score model shows us our dataset values and a predicted values.

我们将添加“得分模型”和“评估模型”。 这些组件可帮助我们评估我们的机器学习模型。 这些组件中的某些值表示模型的准确性。 每种算法都不适用于每个数据集。 因此,我们将评估模型结果。 分数模型向我们显示了我们的数据集值和预测值。

Below you can see the metric, “Coefficient of Determination”. This value defines the accuracy of our model. A value of 1 defines our model is perfect and nearest the “real” result.

您可以在下面看到度量标准“确定系数”。 该值定义了我们模型的准确性。 值1定义我们的模型是完美的,并且最接近“真实”结果。

发布网络服务 (Publish web service)

Our model is ready for publishing. We will publish “Predictive Web Service [Recommended]” then publish the web service.

我们的模型已准备好发布。 我们将发布“ Predictive Web Service [推荐]”,然后发布Web服务。

Note: In this part I added a second duplicate “Select Columns in Dataset” component for reduce web service parameters. So the web service will not request unnecessary columns of the dataset.

注意 :在本部分中,我添加了第二个重复的“数据集中的选择列”组件,以减少Web服务参数。 因此,Web服务将不会请求数据集的不必要的列。

In the predictive experiment screen, we will hook up web service input to the second select columns dataset component and then run our predictive experiment and finally deploy the web service.

在预测性实验屏幕中,我们将Web服务输入连接到第二个选择列数据集组件,然后运行预测性实验并最终部署Web服务。

Our experiment web service will be created on the web service tab. In this tab, we can test our web service. But we don’t use this screen – we’ll click General New Web Services Experience and then Test endpoint link.

我们的实验网络服务将在“网络服务”标签上创建。 在此选项卡中,我们可以测试我们的Web服务。 但是,我们不使用此屏幕-我们将单击General New Web Services Experience ,然后单击Test Endpoint链接。

测试网络服务 (Test web service)

Now we will test our Azure Machine Learning model web service. We will not send the “Cooling Load” parameter to web service because this parameter is output of our web service.

现在,我们将测试我们的Azure机器学习模型Web服务。 我们不会将“ Cooling Load”参数发送到Web服务,因为该参数是我们Web服务的输出。

In this step, we will use web service on R script and integrate it into SQL Server. We can find the prepared code under the use endpoint tab and make some changes to it. I will describe it, in detail, later in the article.

在此步骤中,我们将在R脚本上使用Web服务并将其集成到SQL Server中。 我们可以在“使用端点”选项卡下找到准备好的代码,并对其进行一些更改。 我将在本文后面详细描述它。

Up to this part of the article, we created machine learning model on Azure Machine Learning Studio and created a web service for this model.

到本文的这一部分为止,我们在Azure Machine Learning Studio上创建了机器学习模型,并为此模型创建了一个Web服务。

为R脚本配置SQL Server (Configure SQL Server for R Script)

In this next step, we will enable external scripts on SQL Server for R script integration and then install RCurl, which provides functions to allow one to compose general HTTP requests and provides convenient functions to fetch URIs, get & post forms, etc., and rjson, which converts R objects into JSON objects and vice-versa) packages for R script.)

在下一步中,我们将启用SQL Server上的外部脚本以进行R脚本集成,然后安装RCurl ,它提供的功能允许编写一般的HTTP请求,并提供便利的功能来获取URI,获取和发布表单等,以及rjson ,它将R对象转换为JSON对象,反之亦然)R脚本的包。)

In SSMS you will need to check the configuration for “external scripts enabled”. If this option is “0” we have to change it to 1.

在SSMS中,您需要检查“外部脚本已启用”的配置。 如果此选项为“ 0”,我们必须将其更改为1。

EXEC SP_CONFIGURE 'external scripts enabled';

Now we will enable R script run value.

现在,我们将启用R脚本运行值。

EXEC SP_CONFIGURE 'external scripts enabled',1
GO
RECONFIGURE
GO
EXEC SP_CONFIGURE 'external scripts enabled'

Now that we have enabled external scripts, we will test R script execution.

现在我们启用了外部脚本,我们将测试R脚本的执行。

EXEC sp_execute_external_script@language = N'R',@script = N'print("Hello SQLShack")print("R Script is working")'

Now we will install rcurl and rjson packages on SQL Server R Service:

现在,我们将在SQL Server R Service上安装rcurl和rjson软件包:

  • Open the SQL Server R Services installation path. You can find it in this folder “C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\R_SERVICES\bin” 打开SQL Server R Services安装路径。 您可以在以下文件夹中找到它:“ C:\ Program Files \ Microsoft SQL Server \ MSSQL13.MSSQLSERVER \ R_SERVICES \ bin”
  • Run console with administrator rights 以管理员权限运行控制台

We will install packages

我们将安装软件包

为SQL Server创建R脚本并执行 (Create R Script for SQL Server and Execute)

In this step, we will use ready R script code generated by Azure ML. But we have to make some changes on it.

在此步骤中,我们将使用Azure ML生成的现成的R脚本代码。 但是我们必须对此进行一些更改。

  • We have to replace the API key on R script

    我们必须替换R脚本上的API密钥

  • We have to replace all single quotes to double quotes for SQL Server

    对于SQL Server,我们必须将所有单引号替换为双引号

In this step, we will create an R script and call it from SQL Server. This code will return the result of the web service. We can implement this T-SQL code to Server Reporting Service, Power BI etc. The main architecture of this integration is an R script call Azure ML web service over SQL Server.

在此步骤中,我们将创建一个R脚本并从SQL Server中调用它。 此代码将返回Web服务的结果。 我们可以将该T-SQL代码实现到Server Reporting Service,Power BI等。此集成的主要体系结构是一个R脚本,称为SQL Server上的Azure ML Web服务。

Now we will test this sample.

现在我们将测试该样本。

DECLARE @SurfArea AS FLOAT='735'
DECLARE @WallArea AS FLOAT = '294'
DECLARE @RoofArea AS FLOAT = '220.5'
DROP TABLE IF EXISTS #Pl_Work
CREATE TABLE #Pl_Work
(SurfArea float , WallArea float ,RoofArea Float)INSERT INTO #Pl_Work VALUES(@SurfArea,@WallArea,@RoofArea)EXEC sp_execute_external_script@language = N'R',@script = N'
library("RCurl")
library("rjson")# Accept SSL certificates issued by public Certificate Authorities
options(RCurlOptions = list(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl")))h = basicTextGatherer()
hdr = basicHeaderGatherer()req =  list(Inputs = list("input1"= list(list(''Surface Area'' = InputDataSet$SurfArea,''Wall Area'' = InputDataSet$WallArea,''Roof Area'' = InputDataSet$RoofArea,''Cooling Load'' = "1"))),GlobalParameters = setNames(fromJSON(''{}''), character(0))
)body = enc2utf8(toJSON(req))
api_key = "You have to write your key here" # Replace this with the API key for the web service
authz_hdr = paste(''Bearer'', api_key, sep='' '')h$reset()
curlPerform(url = "https://ussouthcentral.services.azureml.net/workspaces/baf2298a7a714a8dbf56b1ac845e8b8e/services/bac89845b11741cea639723a1bbc4f66/execute?api-version=2.0&format=swagger",
httpheader=c(''Content-Type'' = "application/json", ''Authorization'' = authz_hdr),
postfields=body,
writefunction = h$update,
headerfunction = hdr$update,
verbose = TRUE
)headers = hdr$value()
httpStatus = headers["status"]
if (httpStatus >= 400)
{}
result = h$value()
SQLOut <-  data.frame(result)
',@input_data_1 = N'SELECT * FROM #Pl_Work' ,
@output_data_1_name = N'SQLOut'

These two pictures are showing the same results.

这两张图片显示了相同的结果。

结论 (Conclusion)

In this article, we discussed Azure Machine Learning integration to SQL Server. SQL Server R script provides this integration. The Azure Machine Learning framework that runs in the cloud brings us very flexible environment, which has a high capability with web service integration.

在本文中,我们讨论了Azure机器学习与SQL Server的集成。 SQL Server R脚本提供了这种集成。 在云中运行的Azure机器学习框架为我们带来了非常灵活的环境,该环境具有Web服务集成的高性能。

翻译自: https://www.sqlshack.com/integrate-sql-server-azure-machine-learning/

azure机器学习

azure机器学习_如何集成SQL Server和Azure机器学习相关推荐

  1. sql azure 语法_使用Azure门户监视安装了SQL Server的Azure计算机

    sql azure 语法 介绍 (Introduction) In this new chapter, we will show how to use the Microsoft Portal to ...

  2. sql azure 语法_如何将SQL Server数据库备份到Microsoft Azure

    sql azure 语法 In the last chapter, we explained how to create a Microsoft Azure Account and how to ha ...

  3. sql 2017 机器学习_使用R和SQL Server 2017进行机器学习

    sql 2017 机器学习 The primitive Business Intelligence (BI) methodology has its primary focus on data sou ...

  4. sql azure 语法_如何在SQL 2016中使用Azure Key Vault使用AlwaysOn配置TDE数据库

    sql azure 语法 One of the recent tasks I undertook on configuring Transparent Data encryption (TDE) us ...

  5. SQL索引管理器——用于SQL Server和Azure上的索引维护的免费G​​UI工具

    目录 介绍 主意 实现 结果和计划 下载源 - 16.3 MB 下载 SQL 索引管理器 v1.0.0.68.zip - 16.2 MB 下载 SQL 索引管理器 v1.0.0.67.zip - 16 ...

  6. SQL索引管理器——用于SQL Server和Azure上的索引维护的免费GUI工具

    目录 介绍 理念 实现 结果和计划 介绍 我作为SQL Server DBA工作了8年多,管理和优化服务器的性能.在我的空闲时间,我想为世界和我的同事做一些有用的事情.这就是我们最终为SQL Serv ...

  7. sql azure 语法_如何将SQL数据迁移到Azure Cosmos DB

    sql azure 语法 In this article, I have explained the step by step process of migrating data from SQL S ...

  8. 【Microsoft Azure 的1024种玩法】四十八.基于Azure Virtual Machines快速搭建SQL Server应用

    [简介] SQL Server系列软件是Microsoft 公司推出的关系型数据库管理系统,本文的主要内容是围绕着Azure Virtual Machines 来快速搭建SQL Server应用,使我 ...

  9. ssma迁移助手_如何使用SQL Server迁移助手(SSMA)和SSIS将MySQL表迁移到SQL Server

    ssma迁移助手 介绍 (Introduction) In this article, we will demonstrate how to migrate MySQL tables to SQL S ...

最新文章

  1. 字符串操作(Java)
  2. 一文读懂生物医学领域的传感器
  3. Java常用分析工具Jps、Jstat、Jinfo、Jstack以及Jconsole的简单介绍和使用
  4. mysql进阶(十五) mysql批量删除大量数据
  5. 闲鱼如何在2个月内实现Android启动速度翻倍的?
  6. 字符串GZIP压缩解压
  7. the job was canceled什么意思_宇宙中的第一种颜色是什么?
  8. 电商项目实战项目需求以及技术选型
  9. 趋势 | AI技能排行榜:TensorFlow热度飙升,Python最火
  10. 原 python下DataFrame, Series, ndarray, list, dict, tuple的相互转换
  11. 烟草MES系统介绍-序
  12. VLC播放电视直播rtmp流地址
  13. 利用数据细分目标客户群
  14. oracle恢复表数据
  15. proteus 安装包以及破解汉化
  16. python实现随机抽奖游戏
  17. 计算机一级windows7操作,高校计算机一级考试指导书(Windows7+Office2010)
  18. Android音频数据格式概述
  19. 2017年江苏高考数学14题
  20. 单个html页面面包屑,充分利用网页设计中的面包屑

热门文章

  1. 数据结构与算法2——线性顺序存储
  2. SignalR循序渐进(三)简易的集群通讯组件
  3. 怎么解决php页面编码问题,PHP页面编码问题
  4. java代码实现画板_求好心人帮找或做个JAVA画板程序 代码,主要能实现简单的画板功能!...
  5. powershell写mysql_使用Powershell对MySql运行MySql存储过程脚本
  6. 力扣 填充每个节点的下一个右侧节点指针
  7. 程序员如果不能干到退休,那程序员的路何去何从?
  8. TrueNAS Enterprise是什么
  9. 在承德避暑山庄里待过,给你的最大感受是什么?
  10. 女儿还有三个月就高考了,最近压力大,特别敏感,容易发火怎么办?