This article provides a comprehensive list of the tutorials, demos, and sample applications that use R or Python with SQL Server 2016 or SQL Server 2017. Start here to learn how to run R or Python from T-SQL, use remote and local compute contexts, and optimize your R and Python code for a SQL production environment.
Samples are real-world scenarios for embedding machine learning in applications. All samples include code that you can download, modify, and use in production.
Solutions from the Microsoft Data Science team demonstrate end-to-end scenarios. Most are designed to run either in SQL Server or in a cloud environment such as Azure machine Learning.
For more information about requirements and how to get set up, see Prerequisites.
To use these tutorials and samples, you must have installed one of the following server products:
SQL Server 2016 R Services (In-Database)
Supports R. Be sure to install the machine learning features, and then enable external scripting.
SQL Server 2017 Machine Learning Services (In-Database)
Supports either R or Python. You must select the machine learning feature and the language to install, and then enable external scripting.
For more information about setup, see Prerequisites.
Support for Python is a new feature in SQL Server 2017, beginning with CTP 2.0. Although the feature is in pre-release and not supported for production environments, we invite you to try it out and send feedback.
These samples and demos provided by the SQL Server and R Server development team highlight ways that you can use embedded analytics in real-world applications.
Learn how a ski rental business might use machine learning to predict future rentals, which helps the business plan and staff to meet future demand.
Build the ski rental analysis application using Python, to help plan for future demand.
Use unsupervised learning to segment customers based on sales data.
Learn about Microsoft R
Wondering what the RevoScaleR package offers? See these tutorials:
These R Server tutorials demonstrate how you can write R code once and deploy anywhere, using RevoScaleR data sources and remote compute contexts.
Learn how to use the new algorithms in the MicrosoftML package for advanced modeling and scalable data transformations, optimized for multiple compute contexts.
The Microsoft Data Science Team has provided solution templates that can be used to jump-start solutions for common scenarios. All T-SQL and R code is provided, along with instructions on how to train and deploy a model for scoring using SQL Server stored procedures.
For more information, see Machine Learning Templates with SQL Server 2016 R Services.
Resources and reading
- Want to know the real story behind R Services? Read this article from the development and PM team: Why did we build it?
To run these tutorials, you must download and install the SQL Server machine learning components, as described here:
With SQL Server 2017 CTP 2.0, you can install either R or Python, or both. Otherwise the overall setup process, architecture, and requirements are the same.
After running SQL Server setup, don't forget these important steps:
- Enable the external script execution feature by running
sp_configure 'enable external script', 1
- Restart the server
- Ensure that the service that calls the external runtime has necessary permissions
- Ensure that your SQL login or Windows user account has necessary permissions to connect to the server, to read data, and to create any database objects required by the sample
If you run into trouble, see this article for some common issues: Upgrade and Installation of SQL Server R Services
You cannot run these tutorials using just the standard R or Python tools. Both your development environment and the SQL Server computer with machine learning must have the R or Python libraries provided by Microsoft.