0% found this document useful (0 votes)
4 views37 pages

SQLServer MLServer Overview

The document discusses the integration of Machine Learning with SQL Server and ML Server, highlighting the goals, features, and benefits of using these technologies for predictive modeling. It outlines various machine learning approaches, the roles of data scientists, domain experts, and data engineers, as well as the steps to create predictive models. Additionally, it covers the limitations of R, the advantages of Microsoft R Server, and the operationalization of R within SQL Server for enhanced performance and scalability.

Uploaded by

etest2272
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views37 pages

SQLServer MLServer Overview

The document discusses the integration of Machine Learning with SQL Server and ML Server, highlighting the goals, features, and benefits of using these technologies for predictive modeling. It outlines various machine learning approaches, the roles of data scientists, domain experts, and data engineers, as well as the steps to create predictive models. Additionally, it covers the limitations of R, the advantages of Microsoft R Server, and the operationalization of R within SQL Server for enhanced performance and scalability.

Uploaded by

etest2272
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 37

Machine Learning with

SQL Server and ML Server

Bryan Cafferky
Data Solutions Enabler

Subscribe to me on:
GitHub: https://github.com/bcafferky/shared
Predictive Modeling with R
For Language and graphics

Predictive Modeling with R


Goals

• Data Science Collaboration


• SQL Server/Machine Learning Server
• Features and Benefits of Machine Learning Server

Predictive Modeling with R


Azure Supported Machine Learning Approaches
Custom Build Your Own Pre Built
Non Scalable Services
Scalable Scalable
• Poor Scalability • Very High • Pre Trained
• High Scalability
• Language Scalability • Easy to Use
• Support
Dependent • General API • Fitted to a
• Model Purpose
Performance
Varies
Examples:
Examples: Examples: Examples:

Cognitive Services

Open Source Commercial


© Copyright Microsoft Corporation. All rights reserved.

Predictive Modeling with R


Cognitive Services

© Copyright Microsoft Corporation. All rights reserved.

Predictive Modeling with R


Machine Learning Solutions
Partner Solutions

• Pre Built Solutions


• Customize to Your Needs

Examples

© Copyright Microsoft Corporation. All rights reserved.

Predictive Modeling with R


Scale Up vs. Scale Out

Scale Up Scale Out


Predictive Modeling with R
Scale Up vs. Scale Out

Scale Out
Predictive Modeling with R
Scale Up vs. Scale Out

Small Medium Large

Open Source Scale Up Scale Out


Predictive Modeling with R
Statistics & Data Science Roles

• Advanced Degree in Statistics


Data Scientist Model • Research/Discovery Orientated
Selection
• Conceptualize/Develop Models

• Has deep domain knowledge


Domain Expert
Feature • Blends Operational Reporting & Analytics
Selection • Some Knowledge of Statistics
• Less Complex Models/Solutions

• Focuses on Scaling Up/Out and Automation


Data Engineer
Data • May Modify Solution/Model to Scale It
Wrangling • Basic Understanding of Statistics and Models

Predictive Modeling with R


Predictive Modeling, Supervised Learning

Input Data is Fed into the Program


The Program is to Determine the Relationship Between the Input Columns
and a Result Output Column
Based on Analysis of Inputs to Result, a Model is Created to Predict the
Result Based on a Given Set of Inputs

History is used to predict the future.

Predictive Modeling with R


Applications of Predictive ModelingModeling

• What is the level of surgical risk?


• Will a person contract a certain illness?
• Will the patient be readmitted?
• Is the person a high health risk?

Predictive Modeling with R


Applications of Other Forms of Machine Learning

• Extract handwritten notes from images.


• Speech recognition and conversion to text.
• Radiology – is there a tumor on the spine?
• Genomics
• Did a patient fall out of their bed?

Predictive Modeling with R


Steps to Creating a Predictive Model

• Analyze/Clean the Data


• Determine the Columns that Predict the
Answer
• Select a Model to Use
• Train the Model
• Evaluate the Model’s Effectiveness
• Use the Model

Predictive Modeling with R


Steps to Predictive Modeling

Predictive Modeling with R


SQL Server/R Integration

Predictive Modeling with R


SQL Server Machine learning Services

SQL Server 2016 SQL Server 2017


• Extensibility Framework • Python Support (3.5.2)
• R Support (3.2.2) • R Support (3.3.3)
• Microsoft R Server • Native Scoring using PREDICT
• In-database Package
Management

Predictive Modeling with R


R Limitations

Client side only tool. No server based processing.

Data limited by client memory.

Single threaded.

Database data must be imported to be used.

Relatively slow.

No scheduling tool.

Predictive Modeling with R


Microsoft buys Revolution
Analytics
Proprietary vendor providing scalability
options.
Support for multi-threading.
Provide a shared R server.
Performant versions of common R
functions.
Data not limited by memory.

Predictive Modeling with R


SQL Server 2016: Reaching R's Potential

Stored procedures can be coded in R with the features


that entails.

SQL Server and R share memory space.

Work can be split between SQL Server and R Server.

Predictive Modeling with R


SQL Server 2016: Reaching R's Potential
Stored procedures can be coded in R with the features that entails.

SQL Server and R share memory space so no data movement.

Work can be split between SQL Server (T-SQL) and R Server.

Operationalize with SQL Agent.

Leverage all the Security Features of SQL Server.

Perfect Solution for Machine Learning with Structured Data.


Predictive Modeling with R
L Server Plus R = Value

Predictive Modeling with R


SQL Server Plus Machine Learning Server = Value

Python Python/R
Stored
and R Procedures/
Functions
Supported

Predictive Modeling with R


L Server: R Operationalized

https://msdn.microsoft.com/en-us/library/mt590947.aspx
Predictive Modeling with R
L Server: R Operationalized

https://www.youtube.com/watch?v=by2cJ9sQO0Q
Predictive Modeling with R
L Server/R Architecture

Predictive Modeling with R https://www.youtube.com/watch?v=by2cJ9sQO0Q


Microsoft R Open
R Open - an open source R distribution from Microsoft that is fixed stable
release.

CRAN is always adding updates to the R language which can be unstable.

Some enhanced performance math functions are included.

Is used in place of the standard CRAN R language download.

Must be used with R scalability features.

Predictive Modeling with R


Microsoft R Client

Is a set of R packages.

Implements RScale functions but with limited scalability.

Useful for learning and development.

May be a good option when small only scale improvments


are needed.

Predictive Modeling with R


Microsoft R Server

A stand alone R execution environment.

Clients submit R requests to R Server for high speed processing.

Can be contained within other environments such as SQL Server.

Versions for Linux, Hadoop and Teradata.

Tight integration with SQL Sever.

Predictive Modeling with R


SQL Server: DeployR

Known as the R Integration Server.

An optional framework for deploying R analytics inside web, desktop, mobile, and
dashboard applications as well as backend systems.

Provides analytics services such as a predictive model as a web service.

Predictive Modeling with R


SQL Server Launchpad Service

Predictive Modeling with R


Demo

SQL Server R Services Demo

Predictive Modeling with R


Adding Python Support

Predictive Modeling with R


QL Server/ML Server with Python
#If you are running SQL Server 2017 RC1 and above: #Get the data from SQL Server Table
from revoscalepy import data_source =
RxComputeContext, RxInSqlServer, RxSqlServerData(table="dbo.rental_data",
RxSqlServerData connection_string=conn_str,
from revoscalepy import rx_import column_info=column_info)
#Connection string to connect to SQL Server instance
computeContext = RxInSqlServer(
conn_str = 'Driver=SQL connection_string = conn_str,
Server;Server=MYSQLSERVER;Database=Tu num_tasks = 1,
torialDB;Trusted_Connection=True;' auto_cleanup = False
)
#Define the columns we wish to import
column_info = {
"Year" : { "type" : "integer" }, RxInSqlServer(connection_string=conn_str,
"Month" : { "type" : "integer" }, num_tasks=1, auto_cleanup=False)
"Day" : { "type" : "integer" },
"RentalCount" : { "type" : "integer" },
"WeekDay" : {
# import data source and convert to pandas dataframe
"type" : "factor", df = pd.DataFrame(rx_import(input_data =
"levels" : ["1", "2", "3", "4", "5", "6", "7"] data_source))
}, print("Data frame:", df)
"Holiday" : { # Get all the columns from the dataframe.
"type" : "factor", columns = df.columns.tolist()
"levels" : ["1", "0"]
},
# Filter the columns to remove ones we don't want to use
"Snow" : { in the training
"type" : "factor", columns = [c for c in columns if c not in ["Year"]]
Predictive Modeling
"levels" : ["1", "0"] with R
}
Take A Ways

• Data Does Not Need to Be Moved


• High Performance rx Functions Server Side
• Models Can Be Stored in SQL a Server Table
• Prediction Results Can Be Stored in a SQL Server Table
• R/Python Stored Procedures and Functions
• SQL Agent Can Be Used to Schedule Model Builds
• Use T-SQL or R/Python As Best Fits the Need

Predictive Modeling with R


Q&A

Predictive Modeling with R


QL Server/R Server Integration

Predictive Modeling with R

You might also like