Presentation is loading. Please wait.

Presentation is loading. Please wait.

SQL 2016 R Services a.k.a. leveraging your local data lake

Similar presentations


Presentation on theme: "SQL 2016 R Services a.k.a. leveraging your local data lake"— Presentation transcript:

1 SQL 2016 R Services a.k.a. leveraging your local data lake
January 10, 2017 a.k.a. leveraging your local data lake

2 Kevin Queen kqueen@oakwoodsys.com kevindqueen@outlook.com
Consultant for over 20 years with experience in: BI development (primarily MS SQL Server) Application development (primarily .NET) SCRUM Master Project Management Business Analysis Quality Assurance Team Development Kevin Queen Director at Oakwood Systems Group Inc.

3 Agenda 1 Overview and Why R in SQL 2 Architecture and Setting Up 3
Demo using stored procedures 3 Demo using remote client 4

4 General Process Overview
Obtain data Model, Train, Test and Evaluate Present and Incorporate into Solutions Define the problem and desired outcome Data Munge These are iterative processes. However your organization depicts this, the end goal is Actionable Intelligent Information. Building results into solutions enhances the return on investment.

5 Why R in SQL Server? Traditional R development has commonly been done in a stand alone desktop environment. Limited memory (and R works “in memory”) Have to download data Need to individually update packages and R

6 Why R in SQL Server? – bring the code to the data
SQL Server may already have your data Larger memory than work station (hopefully) Ability to use SQL and R in combination Ease of integration into applications to leverage and apply models, predictors, etc. Still have to manage packages and updates (but more on this later) R Server can also run stand alone, or on Hadoop, and other platforms – but this presentation focuses on SQL Server R

7 Development Environment (Client Server)
Microsoft OpenR is required – ScaleR handles distributing the workload between the client and the server as well as parallel processing – ‘rx’

8 Production Environment
No matter how you develop the R scripts, in database R services provides ease of execution for production use.

9 Keys to Using SQL R Services
Leverage stored procedures to run R scripts (similar to AzureML R module) Import table, view or query as a data set Perform R commands Export results to database R script development is still on the developer desktop Need Server admin privileges to install packages on server. R versions are controlled by SQL updates. Graphics outputs are downloaded from DB Graphics can be incorporated into SSRS Leverage Open R Server / Client to run client side scripts on the server R script development is still on the developer desktop but accesses full database which remains on server Need Server admin privileges to install packages on server – though a fix is promised. Must sync Open R versions client/server ScaleR package (comes with Open R) required as this handles splitting tasks on client vs server Can use full database datasets SQLBindR may address problem with R sync

10 Getting Set Up on the Server
The easy part: Install R Services as an option in SQL Server 2016 SP1 (any edition should work with SP1) Almost as easy: Go to your R Service install for the specific SQL instance and install any needed packages. Admin console go to C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\R_SERVICES\bin> (default instance and location) Run R.exe and install.packages() with lib = the corresponding library folder. Each SQL instance has its own R environment!

11 Getting Set Up on the Client
Install an IDE (RStudio*, Microsoft R Client, or RTools for Visual Studio 2015) * You will also need to install Open R and set that as your R environment You may have to update R Server to V 9.0 -- contains fix -- more info

12 Demo – using R in Stored Procedures
SSMS – SQL-R-Exploration.sql SQL Name R Module Name in SQL @input_data_1 InputDataSet @output_data_1_name=N’name’ Dataframe in R named ‘name’ @params = varbinary(max) Dataframe called “model” Stored procedure returns OutputDataSet Homework: follow the above but actually score the model

13 Demo – using Remote Client
VS 2015 – SQLRWalk.R Requires ScaleR library Compute Context set up to manage client-server transfers Notice impact of “marshalling” between client and server Use the .R file you download, not what is shown on the web pages as they fixed errors in the file only. Homework: follow the above but actually score the model

14 Conclusions Pros Ability to run against larger data sets using server Ability to leverage existing data in SQL Ability to leverage SQL and R both in solutions Ability to incorporate R in other applications Cons SQL Server will need more memory Maintaining libraries and version synch is more difficult – though a fix is promised and SQLBindR may be an interim help RevoScaleR is a whole new way of life

15 Resources – edX.org Good all around capabilities reference with tutorials Known Issues  Synching R Server and R Client ScaleR Tutorial Set Up


Download ppt "SQL 2016 R Services a.k.a. leveraging your local data lake"

Similar presentations


Ads by Google