Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Data Science with SQL Server Quick Start Guide

You're reading from   Data Science with SQL Server Quick Start Guide Integrate SQL Server with data science

Arrow left icon
Product type Paperback
Published in Aug 2018
Publisher Packt
ISBN-13 9781789537123
Length 206 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Dejan Sarka Dejan Sarka
Author Profile Icon Dejan Sarka
Dejan Sarka
Arrow right icon
View More author details
Toc

Table of Contents (10) Chapters Close

Preface 1. Writing Queries with T-SQL FREE CHAPTER 2. Introducing R 3. Getting Familiar with Python 4. Data Overview 5. Data Preparation 6. Intermediate Statistics and Graphs 7. Unsupervised Machine Learning 8. Supervised Machine Learning 9. Other Books You May Enjoy

Predicting with T-SQL


The last question to answer is how you use the R and Python models in T-SQL. Of course, you can create the models and train them directly with the sys.sp_execute_external_script stored procedure. However, it would make no sense to retrain the complete model on the same training set for every new prediction, even if it is prediction on a single case. SQL Server 2017 introduces the PREDICT() function. Using this function means performing native predictions in SQL Server. 

In order to use the PREDICT() function, you need to serialize the model in a SQL Server table, in a VARBINARY(MAX) column. You don't even have to have the ML Services (In-Database) installed in the SQL Server where you serialize your models to do the native predictions. The following code creates the table for the models:

CREATE TABLE dbo.dsModels
(Id INT NOT NULL IDENTITY(1,1) PRIMARY KEY,
 ModelName NVARCHAR(50) NOT NULL,
 Model VARBINARY(MAX) NOT NULL);
GO

Unfortunately, not all models are supported...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image