Book Image

Data Science with SQL Server Quick Start Guide

By : Dejan Sarka
Book Image

Data Science with SQL Server Quick Start Guide

By: Dejan Sarka

Overview of this book

SQL Server only started to fully support data science with its two most recent editions. If you are a professional from both worlds, SQL Server and data science, and interested in using SQL Server and Machine Learning (ML) Services for your projects, then this is the ideal book for you. This book is the ideal introduction to data science with Microsoft SQL Server and In-Database ML Services. It covers all stages of a data science project, from businessand data understanding,through data overview, data preparation, modeling and using algorithms, model evaluation, and deployment. You will learn to use the engines and languages that come with SQL Server, including ML Services with R and Python languages and Transact-SQL. You will also learn how to choose which algorithm to use for which task, and learn the working of each algorithm.
Table of Contents (15 chapters)
Title Page
Copyright and Credits
Packt Upsell
Contributors
Preface
Index

Learning the basics of the R language


Now let's write some code that actually executes something:

1 + 2
2 + 5 * 4
3 ^ 4
sqrt(81)
pi

This code first evaluates three mathematical expressions using the basic operators. As you might expect, R evaluates the expressions using the mathematical operator precedence. The code calls the sqrt() function to calculate and checks the value of the constant for the number pi (π). The base R installation, or the base package, has many built-in constants. You can search the help for all pages that mention constants with ??"constants".

There are many ways to generate sequences of numbers, as you can see from the following code:

rep(1, 5)
4:8
seq(4, 8)
seq(4, 20, by = 3)

The first command replicates the number 1 five times with the help of the rep() function. You can generate a sequence of numbers with the help of the colon operator (:), as you can see from the second line. In the third line, I am using the seq() function for the same task. This function has more...