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

Using functions, branches, and loops


You can encapsulate your code inside a function. The def name(): command defines a function name and is the first code in your function definition. Functions include zero or more parameters and can return values. The following is an example of two functions. The first one has no parameters. The second one has two parameters and returns a value.  There is no special ending mark of a function body—as you know, the correct indentation is important. Indentation tells the Python interpreter where the body of one function ends and the next command starts:

def nopar():
    print("No parameters")
def add(a, b):
    return a + b

 

 

When you call a function, you can pass arguments for the parameters as literals, or through variables. You can even do some operations on the arguments when you pass them to the function. The following code shows these possibilities:

# Call without arguments
nopar()
# Call with variables and math
a = 10
b = 20
add(a / 5, b / 4)

Here are...