From 0d13643a241c4ddb7f2cdfa79a4c2426fc1837d3 Mon Sep 17 00:00:00 2001 From: Umachandar Jayachandran Date: Sun, 4 Nov 2018 11:48:03 -0800 Subject: [PATCH] Refactored ML samples --- .../machine-learning/README.md | 4 ++- .../machine-learning/sql/README.md | 24 +++++++----------- .../machine-learning/sql/python/README.md | 21 +++++++++++++++ .../book-click-prediction-partitioned-py.sql | Bin .../{ => python}/book-click-prediction-py.sql | Bin .../machine-learning/sql/r/README.md | 21 +++++++++++++++ .../book-click-prediction-partitioned-r.sql | Bin .../sql/{ => r}/book-click-prediction-r.sql | Bin 8 files changed, 54 insertions(+), 16 deletions(-) create mode 100644 samples/features/sql-big-data-cluster/machine-learning/sql/python/README.md rename samples/features/sql-big-data-cluster/machine-learning/sql/{ => python}/book-click-prediction-partitioned-py.sql (100%) rename samples/features/sql-big-data-cluster/machine-learning/sql/{ => python}/book-click-prediction-py.sql (100%) create mode 100644 samples/features/sql-big-data-cluster/machine-learning/sql/r/README.md rename samples/features/sql-big-data-cluster/machine-learning/sql/{ => r}/book-click-prediction-partitioned-r.sql (100%) rename samples/features/sql-big-data-cluster/machine-learning/sql/{ => r}/book-click-prediction-r.sql (100%) diff --git a/samples/features/sql-big-data-cluster/machine-learning/README.md b/samples/features/sql-big-data-cluster/machine-learning/README.md index a68ba74e..d34971cd 100644 --- a/samples/features/sql-big-data-cluster/machine-learning/README.md +++ b/samples/features/sql-big-data-cluster/machine-learning/README.md @@ -1,7 +1,9 @@ -# Machine learning in SQL Server 2019 big data cluster +# Machine Learning in SQL Server 2019 big data cluster ## SQL Server Machine Learning Services +SQL Server 2016 added capability to run R script from T-SQL. SQL Server 2017 added support for running Python scripts from T-SQL. SQL Server 2019 adds support for running Java code from T-SQL. You can now run R, Python or Java code from T-SQL in SQL Server 2019 on Windows or Linux or SQL Server 2019 big data cluster. + [sql](sql) SQL Server machine learning services samples showing R, Python & Java support. diff --git a/samples/features/sql-big-data-cluster/machine-learning/sql/README.md b/samples/features/sql-big-data-cluster/machine-learning/sql/README.md index ebd7959c..4aa5c22b 100644 --- a/samples/features/sql-big-data-cluster/machine-learning/sql/README.md +++ b/samples/features/sql-big-data-cluster/machine-learning/sql/README.md @@ -1,23 +1,17 @@ -# SQL Server Machine Learning Services on SQL Master instance +# SQL Server Machine Learning Services -[book-click-prediction-r.sql](book-click-prediction-r.sql/) +SQL Server 2016 added capability to run R script from T-SQL. SQL Server 2017 added support for running Python scripts from T-SQL. SQL Server 2019 adds support for running Java code from T-SQL. -In this example, we are building a machine learning model using R and a logistic regression algorithm for a recommendation engine on an online store. Based on existing users' click pattern online and their interest in other categories and demographics, we are training a machine learning model. This model will then be used to predict if the visitor is interested in a given item category using the T-SQL PREDICT function. +**Applies to: SQL Server 2016+, SQL Server 2019, SQL Server 2019 big data cluster** -[book-click-prediction-py.sql](book-click-prediction-py.sql/) +[r](r) -In this example, we are building a machine learning model using Python and a logistic regression algorithm for a recommendation engine on an online store. Based on existing users' click pattern online and their interest in other categories and demographics, we are training a machine learning model. This model will then be used to predict if the visitor is interested in a given item category using the T-SQL PREDICT function. +This folder contains the R samples. -[book-click-prediction-partitioned-r.sql](book-click-prediction-partitioned-r.sql/) +[python](python) -In this example, we are leveraging the new partitioning support (SQL Server 2019) in sp_execute_external_script to partition the input data and run the R script per partition. So we will modify the training script to train model per group of users based on credit rating. The R script will produce N models for the same input data set. +This folder contains the R samples. -[book-click-prediction-partitioned-py.sql](book-click-prediction-partitioned-py.sql/) +[java](java) -In this example, we are leveraging the new partitioning support (SQL Server 2019) in sp_execute_external_script to partition the input data and run the Python script per partition. So we will modify the training script to train model per group of users based on credit rating. The Python script will produce N models for the same input data set. - -### Instructions - -1. Connect to SQL Server Master instance. - -1. Execute the SQL script. +This folder contains the Java samples. diff --git a/samples/features/sql-big-data-cluster/machine-learning/sql/python/README.md b/samples/features/sql-big-data-cluster/machine-learning/sql/python/README.md new file mode 100644 index 00000000..f3030554 --- /dev/null +++ b/samples/features/sql-big-data-cluster/machine-learning/sql/python/README.md @@ -0,0 +1,21 @@ +# SQL Server Machine Learning Services + +SQL Server 2016 added capability to run R script from T-SQL. SQL Server 2017 added support for running Python scripts from T-SQL. SQL Server 2019 adds support for running Java code from T-SQL. + +[book-click-prediction-py.sql](book-click-prediction-py.sql/) + +**Applies to: SQL Server 2017+, SQL Server 2019, SQL Server 2019 big data cluster** + +In this example, we are building a machine learning model using Python and a logistic regression algorithm for a recommendation engine on an online store. Based on existing users' click pattern online and their interest in other categories and demographics, we are training a machine learning model. This model will then be used to predict if the visitor is interested in a given item category using the T-SQL PREDICT function. + +[book-click-prediction-partitioned-py.sql](book-click-prediction-partitioned-py.sql/) + +**Applies to: SQL Server 2019, SQL Server 2019 big data cluster** + +In this example, we are leveraging the new partitioning support (SQL Server 2019) in sp_execute_external_script to partition the input data and run the Python script per partition. So we will modify the training script to train model per group of users based on credit rating. The Python script will produce N models for the same input data set. + +## Instructions + +1. Connect to SQL Server or SQL Server Master instance. + +1. Execute the SQL script. diff --git a/samples/features/sql-big-data-cluster/machine-learning/sql/book-click-prediction-partitioned-py.sql b/samples/features/sql-big-data-cluster/machine-learning/sql/python/book-click-prediction-partitioned-py.sql similarity index 100% rename from samples/features/sql-big-data-cluster/machine-learning/sql/book-click-prediction-partitioned-py.sql rename to samples/features/sql-big-data-cluster/machine-learning/sql/python/book-click-prediction-partitioned-py.sql diff --git a/samples/features/sql-big-data-cluster/machine-learning/sql/book-click-prediction-py.sql b/samples/features/sql-big-data-cluster/machine-learning/sql/python/book-click-prediction-py.sql similarity index 100% rename from samples/features/sql-big-data-cluster/machine-learning/sql/book-click-prediction-py.sql rename to samples/features/sql-big-data-cluster/machine-learning/sql/python/book-click-prediction-py.sql diff --git a/samples/features/sql-big-data-cluster/machine-learning/sql/r/README.md b/samples/features/sql-big-data-cluster/machine-learning/sql/r/README.md new file mode 100644 index 00000000..09c9ba03 --- /dev/null +++ b/samples/features/sql-big-data-cluster/machine-learning/sql/r/README.md @@ -0,0 +1,21 @@ +# SQL Server Machine Learning Services + +SQL Server 2016 added capability to run R script from T-SQL. SQL Server 2017 added support for running Python scripts from T-SQL. SQL Server 2019 adds support for running Java code from T-SQL. + +[book-click-prediction-r.sql](book-click-prediction-r.sql/) + +**Applies to: SQL Server 2016+, SQL Server 2019, SQL Server 2019 big data cluster** + +In this example, we are building a machine learning model using R and a logistic regression algorithm for a recommendation engine on an online store. Based on existing users' click pattern online and their interest in other categories and demographics, we are training a machine learning model. This model will then be used to predict if the visitor is interested in a given item category using the T-SQL PREDICT function. + +[book-click-prediction-partitioned-r.sql](book-click-prediction-partitioned-r.sql/) + +**Applies to: SQL Server 2019, SQL Server 2019 big data cluster** + +In this example, we are leveraging the new partitioning support (SQL Server 2019) in sp_execute_external_script to partition the input data and run the R script per partition. So we will modify the training script to train model per group of users based on credit rating. The R script will produce N models for the same input data set. + +## Instructions + +1. Connect to SQL Server or SQL Server Master instance. + +1. Execute the SQL script. diff --git a/samples/features/sql-big-data-cluster/machine-learning/sql/book-click-prediction-partitioned-r.sql b/samples/features/sql-big-data-cluster/machine-learning/sql/r/book-click-prediction-partitioned-r.sql similarity index 100% rename from samples/features/sql-big-data-cluster/machine-learning/sql/book-click-prediction-partitioned-r.sql rename to samples/features/sql-big-data-cluster/machine-learning/sql/r/book-click-prediction-partitioned-r.sql diff --git a/samples/features/sql-big-data-cluster/machine-learning/sql/book-click-prediction-r.sql b/samples/features/sql-big-data-cluster/machine-learning/sql/r/book-click-prediction-r.sql similarity index 100% rename from samples/features/sql-big-data-cluster/machine-learning/sql/book-click-prediction-r.sql rename to samples/features/sql-big-data-cluster/machine-learning/sql/r/book-click-prediction-r.sql