Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit f8e0c72

Browse files
committed
added native scoring samples
1 parent fa54ea7 commit f8e0c72

5 files changed

Lines changed: 41 additions & 42 deletions

docs/advanced-analytics/known-issues-for-sql-server-machine-learning-services.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: "Known issues in Machine Learning Services | Microsoft Docs"
33
ms.custom:
44
- "SQL2016_New_Updated"
5-
ms.date: "09/13/2017"
5+
ms.date: "09/19/2017"
66
ms.prod: "sql-server-2016"
77
ms.reviewer: ""
88
ms.suite: ""
@@ -303,15 +303,10 @@ For compatibility with [!INCLUDE[rsql_productname](../includes/rsql-productname-
303303

304304
Revision 0.92 of the SQLite ODBC driver is incompatible with RevoScaleR. Revisions 0.88-0.91 and 0.93 and later are known to be compatible.
305305

306-
## Python code execution or package issues
306+
## Python code execution or Python package issues
307307

308308
This section contains known issues that are specific to running Python on SQL Server, as well as issues that are related to the Python packages published by Microsoft, including [revoscalepy](https://docs.microsoft.com/r-server/python-reference/revoscalepy/revoscalepy-package) and [microsoftml](https://docs.microsoft.com/r-server/python-reference/microsoftml/microsoftml-package).
309309

310-
### Content of varbinary(max) data type is truncated when passed to Python
311-
312-
If you are using Python script in the CTP 2.0 release of SQL Server 2017, and pass data such as images using the varbinary(max) data type, the data might be truncated.
313-
314-
The reason is that early preview releases did not provide the correct mapping of the SQL varbinary(max) data type to the Python byte data type. This issue is fixed in the RTM version. We recommend that you upgrade as soon as possible.
315310

316311
## See also
317312

docs/advanced-analytics/sql-native-scoring.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
title: "Native scoring| Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "07/16/2017"
5-
ms.prod: "sql-server-2016"
4+
ms.date: "09/19/2017"
5+
ms.prod: "sql-server-2017"
66
ms.reviewer: ""
77
ms.suite: ""
88
ms.technology:
@@ -34,9 +34,10 @@ To support fast scoring, SQL Server Machine Learning Services (and Microsoft Mac
3434

3535
**Native scoring**
3636

37-
+ The PREDICT function in Transact-SQL can be used for _native scoring_ from any instance of SQL Server 2017. It requires only that you have a model already trained and saved in a table or can be called via T-SQL. It is a kind of realtime scoring that uses native T-SQL functions; no additional configuration required.
37+
+ The PREDICT function in Transact-SQL can be used for _native scoring_ from any instance of SQL Server 2017. It requires only that you have a model already trained and saved in a table or can be called via T-SQL. It is a kind of realtime scoring that uses native T-SQL functions, with these advantages:
3838

39-
The R runtime is not called and does not need to be installed.
39+
+ No additional configuration is required.
40+
+ The R runtime is not called and does not need to be installed.
4041

4142
**Realtime scoring**
4243

@@ -65,6 +66,11 @@ For code samples, along with instructions on how to prepare the models in the re
6566

6667
+ [How to perform realtime scoring](r/how-to-do-realtime-scoring.md)
6768

69+
For a complete solution that includes native scoring, see these samples from the SQL Server development team:
70+
71+
+ Deploy your ML script: [Using a Python model](https://microsoft.github.io/sql-ml-tutorials/python/rentalprediction/step/3.html)
72+
+ Deploy your ML script: [Using an R model](https://microsoft.github.io/sql-ml-tutorials/R/rentalprediction/step/3.html)
73+
6874
## Requirements
6975

7076
Supported platforms are as follows:

docs/advanced-analytics/tutorials/run-python-using-t-sql.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
title: "Run Python using T-SQL | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "07/31/2017"
5-
ms.prod: "sql-server-2016"
4+
ms.date: "09/19/2017"
5+
ms.prod: "sql-server-2017"
66
ms.reviewer: ""
77
ms.suite: ""
88
ms.technology:
@@ -121,7 +121,7 @@ GO
121121
122122
## Step 3. View the results
123123

124-
The stored procedure returns the original data, applies the script, and then returns the modified data in the **Results** pane of Management Studio or other SQL query tool.
124+
The stored procedure gets the original data, applies the Python script, and then returns the modified data in the **Results** pane of Management Studio or other SQL query tool.
125125

126126

127127
|DayOfWeek (before)| Amount|DayOfWeek (after) |
@@ -167,7 +167,9 @@ ParamINT=2
167167
ParamCharN=OUTPUT
168168
```
169169

170-
+ The Message output includes the working directory used for script execution. In this example, MSSQLSERVER01 refers to the worker account allocated by SQL Server to manage the job. The GUID is the name of a temporary folder that is created during script execution to store data and script artifacts. These temporary folders are secured by SQL Server, and are cleaned up by the Windows job object after script has terminated.
170+
+ The **Message** output includes the working directory used for script execution. In this example, MSSQLSERVER01 refers to the worker account allocated by SQL Server to manage the job.
171+
172+
The GUID is the name of a temporary folder that is created during script execution to store data and script artifacts. These temporary folders are secured by SQL Server, and are cleaned up by the Windows job object after script has terminated.
171173

172174
+ The section containing the message "Hello World" prints two times. This happens because the value of *@RowsPerRead* was set to 5 and there are 10 rows in the table; therefore, two calls to Python are required to process all the rows in the table.
173175

@@ -178,9 +180,9 @@ ParamCharN=OUTPUT
178180
See these additional Python samples and tutorials for advanced tips and end-to-end demos.
179181

180182
+ [Use Python revoscalepy to create a model](use-python-revoscalepy-to-create-model.md)
181-
+ [In-Database Python for SQL Developers](sqldev-in-database-python-for-sql-developers.md)
183+
+ [In-Database Python for SQL developers](sqldev-in-database-python-for-sql-developers.md)
182184
+ [Build a predictive model using Python and SQL Server](https://microsoft.github.io/sql-ml-tutorials/python/rentalprediction/)
183185

184186
## Troubleshooting
185187

186-
If you can't find the stored procedure, `sp_execute_external_script`, it means you probably haven't finished configuring the instance to support external runtimes. After running SQL Server 2017 setup and selecting Python as the machine learning language, you must also explicitly enable the feature using `sp_configure`, and then restart the instance. For details, see [Setup Machine Learning Services with Python](../python/setup-python-machine-learning-services.md).
188+
If you can't find the stored procedure, `sp_execute_external_script`, it means you probably haven't finished configuring the instance to support external script execution. After running SQL Server 2017 setup and selecting Python as the machine learning language, you must also explicitly enable the feature using `sp_configure`, and then restart the instance. For details, see [Setup Machine Learning Services with Python](../python/setup-python-machine-learning-services.md).

docs/advanced-analytics/tutorials/sql-server-python-tutorials.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: "SQL Server Python tutorials | Microsoft Docs"
33
ms.custom:
44
- "SQL2016_New_Updated"
5-
ms.date: "08/29/2017"
5+
ms.date: "09/19/2017"
66
ms.prod: "sql-server-2017"
77
ms.reviewer: ""
88
ms.suite: ""
@@ -41,10 +41,6 @@ For information about requirements and setup, see [Prerequisites](#bkmk_Prerequi
4141

4242
You'll create a model using **rxLinMod**, from the new **revoscalepy** library. You'll launch the code from a remote Python terminal but the modeling will take place in the SQL Server compute context.
4343

44-
+ [Build a predictive model with Python (GitHub)](https://github.com/Microsoft/sql-server-samples/tree/master/samples/features/machine-learning-services/python/getting-started/rental-prediction)
45-
46-
Create a machine learning model to predict demand for a ski rental business, and operationalize that model for day-to-day demand prediction using stored procedures. All code and data is provided.
47-
4844
+ [In-Database Python analytics for SQL developers](sqldev-in-database-python-for-sql-developers.md)
4945

5046
NEW! Build a complete Python solution using T-SQL stored procedures. All Python code is included.
@@ -61,7 +57,10 @@ These samples and demos provided by the SQL Server development team highlight wa
6157

6258
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.
6359

64-
+ [NEW! Perform customer clustering using Python and SQL Server](https://microsoft.github.io/sql-ml-tutorials/python/customerclustering/)
60+
> [!TIP]
61+
> Now includes native scoring from Python models!
62+
63+
+ [Perform customer clustering using Python and SQL Server](https://microsoft.github.io/sql-ml-tutorials/python/customerclustering/)
6564

6665
Learn how to use the Kmeans algorithm to perform unsupervised clustering of customers.
6766

@@ -77,13 +76,13 @@ To use these tutorials, you must have installed SQL Server 2017 Machine Learning
7776

7877
After running SQL Server setup, don't forget these important steps:
7978

80-
+ Enable the external script execution feature by running `sp_configure 'external scripts enabled', 1`
81-
+ Restart the server
82-
+ Ensure that the service that calls the external runtime has necessary permissions
83-
+ 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
79+
+ Enable the external script execution feature by running `sp_configure 'external scripts enabled', 1`.
80+
+ Restart the server.
81+
+ Ensure that the service that calls the external runtime has necessary permissions.
82+
+ 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.
8483

8584
If you run into trouble, see this article for some common issues: [Troubleshooting Machine Learning Services](../machine-learning-troubleshooting-faq.md)
8685

87-
## See Also
86+
## See also
8887

8988
[R tutorials for SQL Server](sql-server-r-tutorials.md)

docs/advanced-analytics/tutorials/use-python-revoscalepy-to-create-model.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
title: "Use Python with revoscalepy to Create a Model| Microsoft Docs"
33
ms.custom:
44
- "SQL2016_New_Updated"
5-
ms.date: "07/03/2017"
6-
ms.prod: "sql-server-2016"
5+
ms.date: "09/19/2017"
6+
ms.prod: "sql-server-2017"
77
ms.reviewer: ""
88
ms.suite: ""
99
ms.technology:
@@ -17,11 +17,11 @@ manager: "jhubbard"
1717
---
1818
# Use Python with revoscalepy to create a model
1919

20-
This example demonstrates how you can create a logistic regression model in SQL Server, using an algorithm from the **revoscalepy** package.
20+
This example demonstrates how you can create a linear regression model in SQL Server, using an algorithm from the **revoscalepy** package.
2121

2222
The **revoscalepy** package for Python contains objects, transformations, and algorithms similar to those provided for the **RevoScaleR** package for the R language. With this library, you can create a compute context, move data between compute contexts, transform data, and train predictive models using popular algorithms such as logistic and linear regression, decision trees, and more.
2323

24-
For more information, see [What is revoscalepy?](../python/what-is-revoscalepy.md)
24+
For more information, see [What is revoscalepy?](../python/what-is-revoscalepy.md) and the [Python function reference](https://docs.microsoft.com/r-server/python-reference/introducing-python-package-reference)
2525

2626
## Prerequisites
2727

@@ -108,8 +108,8 @@ Let's review the code and highlight some key steps.
108108

109109
A data source is different from a compute context. The _data source_ defines the data used in your code. The _compute context_ defines where the code will be executed.
110110

111-
1. Create Python variables, such as `sql_query` and `sql_connection_string`, that define the source and the data you want to use. Pass these variables to the RxSqlServerData constructor to implement the **data source object** named `data_source`.
112-
2. Create a compute context object by using the **RxInSqlServer** constructor. In this example, you pass the same connection string you defined earlier, on the assumption that the data is on the same SQL Server instance that you will be using as the compute context. However, the data source and the compute context could be on different servers. The resulting **compute context object** is named `sql_cc`.
111+
1. Create Python variables, such as `sql_query` and `sql_connection_string`, that define the source and the data you want to use. Pass these variables to the [RxSqlServerData](https://docs.microsoft.com/r-server/python-reference/revoscalepy/rxsqlserverdata) constructor to implement the **data source object** named `data_source`.
112+
2. Create a compute context object by using the [RxInSqlServer](https://docs.microsoft.com/r-server/python-reference/revoscalepy/rxinsqlserverdata) constructor. In this example, you pass the same connection string you defined earlier, on the assumption that the data is on the same SQL Server instance that you will be using as the compute context. However, the data source and the compute context could be on different servers. The resulting **compute context object** is named `sql_cc`.
113113
3. Choose the active compute context. By default, operations are run locally, which means that if you don't specify a different compute context, the data will be fetched from the data source, and the model-fitting will run in your current Python environment.
114114

115115
### Changing compute contexts
@@ -122,23 +122,20 @@ The same applies in the call to **rxsummary**, where the compute context is reus
122122

123123
`summary = rx_summary("ArrDelay ~ DayOfWeek", data = data_source, compute_context = sql_compute_context)`
124124

125-
You can also use the function **rxsetcomputecontext** to toggle between compute contexts that have already been defined.
125+
You can also use the function [rx_set_computecontext](https://docs.microsoft.com/r-server/python-reference/revoscalepy/rx-set-compute-context) to toggle between compute contexts that have already been defined.
126126

127127
### Setting the degree of parallelism
128128

129-
When you define the compute context, you can also set parameters that control how the data is handled by the compute context. These parameters differ depending on the data source type.
129+
When you define the compute context, you can also set parameters that control how the data is handled by the compute context. These parameters differ depending on the data source type.
130130

131131
For SQL Server compute contexts, you can set the batch size, or provide hints about the degree of parallelism to use in running tasks.
132132

133-
The sample was run on a computer with four processors, so we set the *num_tasks* parameter to 4. If you set this value to 0, SQL Server uses the default, which is to run as many tasks in parallel as possible, under the current MAXDOP settings for the server.
134-
However, even in servers with many processors, the exact number of tasks that might be allocated depends on many other factors, such as server settings, and other jobs that are running.
135-
136-
For more information, see [RxInSqlServer](https://docs.microsoft.com/r-server/r-reference/revoscaler/rxinsqlserver).
133+
The sample was run on a computer with four processors, so we set the *num_tasks* parameter to 4. If you set this value to 0, SQL Server uses the default, which is to run as many tasks in parallel as possible, under the current MAXDOP settings for the server.However, even in servers with many processors, the exact number of tasks that might be allocated depends on many other factors, such as server settings, and other jobs that are running.
137134

138135
## Related samples
139136

140137
See these Python samples and tutorials for advanced tips and end-to-end demos.
141138

142-
+ [In-Database Python for SQL Developers](sqldev-in-database-python-for-sql-developers.md)
139+
+ [In-Database Python for SQL developers](sqldev-in-database-python-for-sql-developers.md)
143140
+ [Build a predictive model using Python and SQL Server](https://microsoft.github.io/sql-ml-tutorials/python/rentalprediction/)
144-
+ [Deploy and Consume Python Models](../python/publish-consume-python-code.md)
141+
+ [Deploy and consume Python Models](../python/publish-consume-python-code.md)

0 commit comments

Comments
 (0)