sql机器学习服务

The R language is one of the most popular languages for data science, machine learning services and computational statistics. There are several IDEs that allow seamless R development. Owing to the growing popularity of the R language, R services have been included by Microsoft in SQL Server 2016 onwards. In this article, we will briefly review how we can integrate R with SQL Server 2017. We will see the installation process and will also execute the basic R commands in SQL Server 2017.

R语言是用于数据科学,机器学习服务和计算统计的最受欢迎的语言之一。 有几种IDE可以进行无缝的R开发。 由于R语言的日益普及,R服务已被Microsoft包含在SQL Server 2016及更高版本中。 在本文中,我们将简要回顾如何将R与SQL Server 2017集成。我们将看到安装过程,还将执行SQL Server 2017中的基本R命令。

环境设定 (Environment Setup)

To run R scripts in SQL Server, you have to install Machine Learning Services in SQL Server, which can be done in two different ways. You can install machine learning services to an existing installation of SQL Server or you can configure to install these services with a fresh installation of SQL Server. In this article we will see the second approach where we will download a new version of SQL Server 2017 with machine learning services enabled. To do so, follow these steps:

要在SQL Server中运行R脚本,您必须在SQL Server中安装机器学习服务,这可以通过两种不同的方式来完成。 您可以将机器学习服务安装到现有SQL Server安装中,也可以配置为通过全新安装SQL Server安装这些服务。 在本文中,我们将看到第二种方法,其中我们将下载启用了机器学习服务SQL Server 2017新版本。 这样做,请按照下列步骤操作:

  1. Go to the SQL Server 2017 download link, and select the Developer version of SQL Server for downloading as shown below:

    转到SQL Server 2017下载链接 ,然后选择要下载SQL Server开发人员版本,如下所示:

  2. Once the download is complete, open the “downloaded” executable file. You should see the following options:

    下载完成后,打开“下载的”可执行文件。 您应该看到以下选项:

    Machine Learning Services is an optional feature which is not installed by default in SQL Server Management Studio. To install these services manually, click the Custom installation from the three options you see in the above screenshot.

    机器学习服务是一项可选功能,默认情况下不会在SQL Server Management Studio中安装。 要手动安装这些服务,请从上面的屏幕快照中看到的三个选项中单击“自定义安装”。

  3. A new window will appear where you have to specify the installation path.

    将出现一个新窗口,您必须在其中指定安装路径。

    Specify the installation path and click “Install” button. The download will take some time before the installation window appears.

    指定安装路径,然后单击“安装”按钮。 在安装窗口出现之前,下载将花费一些时间。

  4. From the window that appears select “Installation” option from the left. You will see several options on the right. Select the first one which reads “New SQL Server stand-alone installation or add features to an existing installation”. This is shown in the following figure:

    在出现的窗口中,从左侧选择“安装”选项。 您将在右侧看到几个选项。 选择第一个阅读“新SQL Server独立安装或向现有安装添加功能”。 如下图所示:

  5. Select free “Developer” edition from the window that appears and click “Next” button. Accept the License Agreement and click “Next” button again. Walk through each step until you reach the “Feature Selection” window. 从出现的窗口中选择免费的“ Developer”版本,然后单击“ Next”按钮。 接受许可协议,然后再次单击“下一步”按钮。 逐步执行每个步骤,直到到达“功能选择”窗口。
  6. From the feature selection window select “Database Engine Services.” Under the “Database Engine Service” option, you should see “Machine Learning Services (In Database)” option, which further contains R and Python options. Select both R and Python options as shown below:

    在功能选择窗口中,选择“数据库引擎服务”。 在“数据库引擎服务”选项下,您应该看到“机器学习服务(在数据库中)”选项,其中进一步包含R和Python选项。 选择R和Python选项,如下所示:

    Click “Next” button.

    点击“下一步”按钮。

  7. Give name to your SQL Server instance in the window that appears. You can also use default name and then click “Next” button.

    在出现的窗口中为您SQL Server实例命名。 您也可以使用默认名称,然后单击“下一步”按钮。

  8. Walk through each step until you reach the “Database Engine Configuration” option as shown below:

    逐步执行每个步骤,直到达到“数据库引擎配置”选项,如下所示:

    Here you can click “Add Current User” button to add yourself as the database administrator. Click “Next” button.

    在这里,您可以单击“添加当前用户”按钮将自己添加为数据库管理员。 点击“下一步”按钮。

  9. A window will appear prompting you to give consent to install “Microsoft R Open” as shown below:

    出现一个窗口,提示您同意安装“ Microsoft R Open”,如下所示:

    Click “Accept” button and then click “Next” button.

    单击“接受”按钮,然后单击“下一步”按钮。

  10. Repeat Step 9 to give consent for installing Python Services. 重复步骤9,以同意安装Python Services。
  11. “Feature Configuration Rules” window will appear. Click “Next” button. 将出现“功能配置规则”窗口。 点击“下一步”按钮。
  12. Finally in the “Ready to Install” window, click “Install” button as shown below:

    最后,在“准备安装”窗口中,单击“安装”按钮,如下所示:

  13. Depending upon your processor speed and the internet, the installation process can take some time. Once the installation is complete, you should see the following window:

    根据您的处理器速度和互联网,安装过程可能需要一些时间。 安装完成后,您将看到以下窗口:

    If you see the above window, the installation is successful.

    如果看到以上窗口,则说明安装成功。

启用机器学习服务 (Enabling Machine Learning Services)

In the previous section, we installed the machine learning services required to run R scripts in SQL Server. However, the services are not enabled by default.

在上一节中,我们安装了在SQL Server中运行R脚本所需的机器学习服务。 但是,默认情况下未启用服务。

To enable the machine learning services, go to SQL Server Management Studio. If you have not already installed SQL Server Management Studio, you can download it from this link.

要启用机器学习服务,请转到SQL Server Management Studio。 如果尚未安装SQL Server Management Studio,则可以从此链接下载它。

In the SQL Server Management Studio, open a new query window and type the following script:

在SQL Server Management Studio中,打开一个新的查询窗口,然后键入以下脚本:

EXEC sp_configure 'external scripts enabled', 1
RECONFIGURE WITH OVERRIDE

The script above enables execution of any external scripts in SQL Server. If the above script executes successfully, you should see the following message.

上面的脚本允许执行SQL Server中的任何外部脚本。 如果上面的脚本成功执行,您应该看到以下消息。

Configuration option ‘external scripts enabled’ changed from 0 to 1. Run the RECONFIGURE statement to install.

配置选项“已启用外部脚本”从0更改为1。运行RECONFIGURE语句进行安装。

Before the R scripts can be executed, we need to restart the SQL Server. To do so, open the SQL Server Configuration Manager from the windows start menu. From the options on the left, select “SQL Server Services”. You will see list of all the SQL Server Instances, running on your system as shown below:

在执行R脚本之前,我们需要重新启动SQL Server。 为此,请从Windows的开始菜单中打开SQL Server配置管理器。 从左侧的选项中,选择“ SQL Server服务”。 您将看到在系统上运行的所有SQL Server实例的列表,如下所示:

Right Click the SQL Server Instance that you installed along with machine learning services and click “Restart”.

右键单击与机器学习服务一起安装SQL Server实例,然后单击“重新启动”。

执行R脚本 (Executing R Scripts)

We have installed and enabled the services that are required to run R scripts in SQL Server. Now is the time to run our R script in SQL Server. Execute the following script:

我们已经安装并启用了在SQL Server中运行R脚本所需的服务。 现在是时候在SQL Server中运行我们的R脚本了。 执行以下脚本:

EXEC sp_execute_external_script@language =N'R',@script=N'print("Welcome to R in SQL Server")'
GO

In the first line, we call the “sp_execute_external_script” store procedure; as a parameter we pass it the “language” that the script belongs to and the actual “script”. Notice we passed N‘R’ as language. In the script we simply print a message on the screen. In the console window, you should see the following output when the above script is executed:

在第一行中,我们调用“ sp_execute_external_script”存储过程; 作为参数,我们将脚本所属的“语言”和实际的“脚本”传递给它。 注意我们通过了N'R'作为语言。 在脚本中,我们仅在屏幕上打印一条消息。 在执行上述脚本时,在控制台窗口中,您应该看到以下输出:

STDOUT message(s) from external script: [1] “Welcome to R in SQL Server”

来自外部脚本的STDOUT消息:[1]“欢迎使用SQL Server中的R”

If the corresponding services are installed, the process for running any external script remains the same.

如果安装了相应的服务,则运行任何外部脚本的过程将保持不变。

执行Python脚本 (Executing Python Scripts)

During the installation of machine learning services, we also selected Python. Let’s modify our script to see how Python can be executed inside SQL Server.

在安装机器学习服务期间,我们还选择了Python。 让我们修改脚本以查看如何在SQL Server中执行Python。

Execute the following script:

执行以下脚本:

EXEC sp_execute_external_script@language =N'Python',@script=N'print("Welcome to Python in SQL Server")'
GO

You can see, the only thing we changed here is the language and the text inside the string (which is optional). The output looks like this:

您可以看到,我们在这里所做的唯一更改是字符串中的语言和文本(可选)。 输出看起来像这样:

STDOUT message(s) from external script: Welcome to Python in SQL Server

来自外部脚本的STDOUT消息:欢迎使用SQL Server中的Python

结论 (Conclusion)

In this article, we saw how we can configure SQL Server in order to run R scripts along with the changes we need to make during installation for enabling machine learning services that are required to run R in SQL Server. Finally we ran a simple R script to print the text on screen. By running a Python script, we also proved that the process of running external scripts in SQL server is more or less the same for both of these languages.

在本文中,我们了解了如何配置SQL Server以便运行R脚本以及在安装过程中需要进行的更改,以启用在SQL Server中运行R所需的机器学习服务。 最后,我们运行了一个简单的R脚本以在屏幕上打印文本。 通过运行Python脚本,我们还证明了这两种语言在SQL Server中运行外部脚本的过程大致相同。

本的其他精彩文章 (Other great articles from Ben)

Importing and Working with CSV Files in SQL Server
Machine Learning Services – Configuring R Services in SQL Server
在SQL Server中导入和使用CSV文件
机器学习服务–在SQL Server中配置R服务

翻译自: https://www.sqlshack.com/machine-learning-services-configuring-r-services-in-sql-server/

sql机器学习服务

sql机器学习服务_机器学习服务–在SQL Server中配置R服务相关推荐

  1. java关闭服务_实现优雅地关闭Docker中的java服务

    时至今日,Docker在项目中的应用越来越普遍了,但往往会遭遇一些麻烦,比如说,有几个请求至Docker中的服务,发起了事务处理业务,但每个事务完成可能需要1-5分钟,而此时我们正要将Docker停机 ...

  2. 机器学习 可视化_机器学习-可视化

    机器学习 可视化 机器学习导论 (Introduction to machine learning) In the traditional hard-coded approach, we progra ...

  3. python中引入sql的优点_引用sql-和引用sql相关的内容-阿里云开发者社区

    bboss持久层改进支持模块sql配置文件引用其它模块sql配置文件中sql语句 bboss持久层改进支持模块sql配置文件引用其它模块sql配置文件中sql语句. 具体使用方法如下: <pro ...

  4. linux7系统怎么启动ftp,教你如何在CentOS7系统中配置ftp服务

    本文教你如何在CentOS7系统中配置ftp服务. 1.下载vsftpd yum install -y vsftpd 2.设置开机自启动 systemctl enable vsftpd.service ...

  5. Ubuntu中配置NFS服务

    NFS协议允许远程访问Linux主机中的指定目录,并且在Windows 7中,原生支持将NFS文件系统映射到本地,通过资源管理器就可以访问Linux虚拟机或者开发板中的文件,非常方便. Ubuntu中 ...

  6. VMware windows server 2008配置dns服务

    Windows Server 2008配置 DNS服务 1,打开服务管理器,安装dns服务 2,配置dns服务 进入到刚刚的区域里面建主机 注意这样实际去解析的域名是www.test.com.main ...

  7. ArcGIS Server中的各种服务

    ArcGIS Server中的各种服务 使用服务 通过服务可以在客户端之间更容易的共享资源.通过服务可以保证所有的客户端访问到同样的资源,而不用在他们的机器上单独进行安装. 服务器存储着资源,管理服务 ...

  8. 在IIS中为SQL Server 2008配置报表服务

    不知道是不是SQL Server 2008的Bug,我在安装了SQL2008后(选择了安装报表服务的),但是在IIS中根本没有报表服务的虚拟目录.只是这么一个问题,其他BI设计器.报表服务等都还算正常 ...

  9. 微服务openid等_使用OpenID Connect在Quarkus中保护微服务

    微服务openid等 This is the fourth part in a series on building a microservice from the ground up with Qu ...

最新文章

  1. [微信小程序]物流信息样式加动画效果(源代码附效果图)
  2. [转]/tomcat/conf/server.xml配置文件的源码解析
  3. vba调用计算机,如何实现跨工作表自动引用数据? 求:EXCEL公式(函数)或VBA宏程序...
  4. jsp java语法_javaweb-jsp语法
  5. linux下git的使用
  6. memcached学习(5). memcached的应用和兼容程序
  7. SQL 宝典(本人总结供学习使用)
  8. 【Hadoop Summit Tokyo 2016】欢迎来到Hadoop的青春时代
  9. ERP系统健康体检的三大指标
  10. 4G多卡聚合路由器解决视频直播中的网络不稳定问题
  11. 新手坐高铁怎么找车厢_新手坐高铁怎么找车厢
  12. Detecting Novel Associations in Large Data Sets(检测 大型数据集中的信息关联性,数据相关性)
  13. Kali使用beef
  14. 阿里云redis学习笔记
  15. windows扩充C盘容量(删除Ubuntu分区)
  16. 题解 | Coffee Chicken-2019牛客暑期多校训练营第十场B题
  17. Linux临时解决命令行cat命令中文乱码
  18. 跑模电脑配置、CC集群和空三技巧、三维测图...一整套航测内业实战教程
  19. Linux桌面系统简介
  20. Python编程:朋友圈看起来太low?教你用python实现高逼格朋友圈

热门文章

  1. 海康威视面试-java应用开发
  2. Java 4.表达式
  3. 网上收集的“知乎网”技术方案架构
  4. Android 显示原理简介
  5. 花了两天时间为我的引擎实现了性能分析的界面显示
  6. Babel下的ES6兼容性与规范
  7. 【前端】—每日5道面试题打卡(十六)
  8. 移动端开发——京东首页制作(流式布局)
  9. php 微信扫码给红包,关于现金红包的详细介绍
  10. window safari 怎么进入响应式_Web前端新手怎么入门 如何用CSS做响应式布局