Skip to content
Branch: master
Find file History
Type Name Latest commit message Commit time
Failed to load latest commit information.
Customer Clustering.R Admin:Renaming folders to lower case Feb 2, 2017
Customer Clustering.sql Admin:Renaming folders to lower case Feb 2, 2017 Admin:Renaming folders to lower case Feb 2, 2017
Setup.sql Admin:Renaming folders to lower case Feb 2, 2017

Perform customer clustering with SQL Server R Services

In this sample, we are going to get ourselves familiar with clustering. Clustering can be explained as organizing data into groups where members of a group are similar in some way.


About this sample
Before you begin
Sample details
Related links

About this sample

We will be using the Kmeans algorithm to perform the clustering of customers. This can for example be used to target a specific group of customers for marketing efforts. Kmeans clustering is an unsupervised learning algorithm that tries to group data based on similarities. Unsupervised learning means that there is no outcome to be predicted, and the algorithm just tries to find patterns in the data.

In this sample, you will learn how to perform Kmeans clustering in R and deploying the solution in SQL Server 2016.

Follow the step by step tutorial here to walk through this sample.

  • Applies to: SQL Server 2016 (or higher)
  • Key features:
  • Workload: SQL Server R Services
  • Programming Language: T-SQL, R
  • Authors: Nellie Gustafsson
  • Update history: Getting started tutorial for R Services

Before you begin

To run this sample, you need the following prerequisites. Section 1 in the tutorial covers the prerequisites. After that, you can download a DB backup file and restore it using Setup.sql. Download DB

Software prerequisites:

  1. SQL Server 2016 (or higher) with R Services installed
  2. SQL Server Management Studio
  3. R IDE Tool like Visual Studio

Sample Details

Customer Clustering.R

The R script that performs clustering.

Customer Clustering.SQL

The SQL code to create stored procedure that performs clustering, and queries to verify and take further actions.

Related Links

For additional content, see these articles:

SQL Server R Services - Upgrade and Installation FAQ

Other SQL Server R Services Tutorials

You can’t perform that action at this time.