You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/t-sql/queries/predict-transact-sql.md
+16-17Lines changed: 16 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,14 @@
1
1
---
2
2
title: "PREDICT (Transact-SQL) | Microsoft Docs"
3
3
ms.custom: ""
4
-
ms.date: "07/17/2017"
4
+
ms.date: "02/25/2018"
5
5
ms.prod: "sql-non-specified"
6
6
ms.prod_service: "sql-database"
7
7
ms.service: ""
8
8
ms.component: "t-sql|queries"
9
9
ms.reviewer: ""
10
10
ms.suite: "sql"
11
11
ms.technology:
12
-
13
12
ms.tgt_pltfrm: ""
14
13
ms.topic: "language-reference"
15
14
f1_keywords:
@@ -67,32 +66,34 @@ The DATA parameter is used to specify the data used for scoring or prediction. D
67
66
68
67
The PARAMETERS parameter is used to specify optional user-defined parameters used for scoring or prediction.
69
68
70
-
The name of each parameter is specific to the model type. For example, the rxPredict function in RevoScaleR supports the parameter _@computeResiduals bit_ to support computation of residuals when scoring a logistic regression model. YOu could pass that parameter name and it value to the `PREDICT` function.
69
+
The name of each parameter is specific to the model type. For example, the [rxPredict](https://docs.microsoft.com/machine-learning-server/r-reference/revoscaler/rxpredict) function in RevoScaleR supports the parameter `@computeResiduals`, which indicates whether residuals should be computed when scoring a logistic regression model. If you are calling a compatible model, you could pass that parameter name and a TRUE or FALSE value to the `PREDICT` function.
71
70
72
71
> [NOTE]
73
-
> This option is not supported in the pre-release of SQL Server 2017 and is included for forward-compatibility purposes only.
72
+
> This option does not work in pre-release versions of SQL Server 2017.
74
73
75
-
**WITH ( \<result_set_definition> )**
74
+
**WITH ( <result_set_definition> )**
76
75
77
76
The WITH clause is used to specify the schema of the output returned by the `PREDICT` function.
78
77
79
78
In addition to the columns returned by the `PREDICT` function itself, all the columns that are part of the data input are available for use in the query.
80
79
81
80
### Return values
82
81
83
-
No predefined schema is available; SQL Server does not validate the contents of the model and does not validate the returned column values.
84
-
- The `PREDICT` function passes through columns as input
85
-
- The `PREDICT` function also generates new columns, but the number of columns and their data types depends on the type of model that was used for prediction.
82
+
No predefined schema is available; SQL Server does not validate the contents of the model and does not validate the returned column values.
86
83
87
-
Any error messages related to the data, the model, or the column format are returned by the underlying prediction function associated with the model.
88
-
- For RevoScaleR, the equivalent function is [rxPredict](https://docs.microsoft.com/r-server/r-reference/revoscaler/rxpredict)
89
-
- For MicrosoftML, the equivalent function is [rxPredict.mlModel](https://docs.microsoft.com/r-server/r-reference/microsoftml/rxpredict)
84
+
- The `PREDICT` function passes through columns as input.
85
+
- The `PREDICT` function also generates new columns, but the number of columns and their data types depends on the type of model that was used for prediction.
86
+
87
+
Any error messages related to the data, the model, or the column format are returned by the underlying prediction function associated with the model.
88
+
89
+
- For RevoScaleR, the equivalent function is [rxPredict](https://docs.microsoft.com/machine-learning-server/r-reference/revoscaler/rxpredict)
90
+
- For MicrosoftML, the equivalent function is [rxPredict.mlModel](https://docs.microsoft.com/machine-learning-server/r-reference/microsoftml/rxpredict)
90
91
91
92
It is not possible to view the internal model structure using `PREDICT`. If you want to understand the contents of the model itself, you must load the model object, deserialize it, and use appropriate R code to parse the model.
92
93
93
94
## Remarks
94
95
95
-
The `PREDICT` function is supported in all editions of SQL Server, including Linux.
96
+
The `PREDICT` function is supported in all editions of SQL Server, including Linux, and in Azure SQL Database, regardless of whether other machine learning features are enabled. However, SQL Server 2017 or later is required.
96
97
97
98
It is not necessary that R, Python, or another machine learning language be installed on the server to use the `PREDICT` function. You can train the model in another environment and save it to a SQL Server table for use with `PREDICT`, or call the model from another instance of SQL Server that has the saved model.
98
99
@@ -113,7 +114,7 @@ The following examples demonstrate the syntax for calling `PREDICT`.
113
114
This example calls an existing logistic regression model stored in table [models_table]. It gets the latest trained model, using a SELECT statement, and then passes the binary model to the PREDICT function. The input values represent features; the output represents the classification assigned by the model.
114
115
115
116
```sql
116
-
DECLARE @logit_model varbinary(max) ="SELECT TOP 1 @model from [models_table]";
117
+
DECLARE @logit_model varbinary(max) ="SELECT TOP 1 [model_binary] from [models_table] ORDER BY [trained_date] DESC";
117
118
DECLARE @input_qry ="SELECT ID, [Gender], [Income] from NewCustomers";
118
119
119
120
SELECT PREDICT [class]
@@ -131,7 +132,7 @@ FROM PREDICT(MODEL = @logit_model,
131
132
DATA =dbo.mytableAS d) WITH (Score float) AS p;
132
133
```
133
134
134
-
The alias **d** specified for table source in the _DATA_ parameter is used to reference the columns belonging to dbo.mytable. The alias **p** specified for the **PREDICT** function is used to reference the columns returned by the PREDICT function.
135
+
The alias **d** specified for table source in the `DATA` parameter is used to reference the columns belonging to dbo.mytable. The alias **p** specified for the **PREDICT** function is used to reference the columns returned by the PREDICT function.
135
136
136
137
### Combining PREDICT with an INSERT statement
137
138
@@ -180,7 +181,7 @@ logitObj <- rxLogit(Kyphosis ~ Age + Start + Number, data = kyphosis, covCoef =
180
181
181
182
If you store the model in SQL Server in binary format, you can use the PREDICT function to generate not just predictions, but additional information supported by the model type, such as error or confidence intervals.
182
183
183
-
The following code shows the equivalent call from R to rxPredict:
184
+
The following code shows the equivalent call from R to [rxPredict](https://docs.microsoft.com/machine-learning-server/r-reference/revoscaler/rxpredict):
Copy file name to clipboardExpand all lines: docs/t-sql/statements/alter-external-library-transact-sql.md
+20-18Lines changed: 20 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,14 @@
1
1
---
2
2
title: "ALTER EXTERNAL LIBRARY (Transact-SQL) | Microsoft Docs"
3
3
ms.custom: ""
4
-
ms.date: "10/05/2017"
4
+
ms.date: "02/25/2018"
5
5
ms.prod: "sql-non-specified"
6
6
ms.prod_service: "database-engine"
7
7
ms.service: ""
8
8
ms.component: "t-sql|statements"
9
9
ms.reviewer: ""
10
10
ms.suite: "sql"
11
11
ms.technology:
12
-
13
12
ms.tgt_pltfrm: ""
14
13
ms.topic: "language-reference"
15
14
f1_keywords:
@@ -31,7 +30,7 @@ Modifies the content of an existing external package library.
31
30
32
31
## Syntax
33
32
34
-
```
33
+
```text
35
34
ALTER EXTERNAL LIBRARY library_name
36
35
[ AUTHORIZATION owner_name ]
37
36
SET <file_spec>
@@ -59,6 +58,8 @@ WITH ( LANGUAGE = 'R' )
59
58
60
59
Specifies the name of an existing package library. Libraries are scoped to the user. That is, library names are considered unique within the context of a specific user or owner.
61
60
61
+
The library name cannot be arbitrarily assigned. That is, you must use the name that the calling runtime expects when it loads the package.
62
+
62
63
**owner_name**
63
64
64
65
Specifies the name of the user or role that owns the external library.
@@ -80,7 +81,11 @@ Specifies the name of the external data source that contains the location of the
80
81
81
82
**library_bits**
82
83
83
-
Specifies the content of the package as a hex literal, similar to assemblies. This option allows users to create a library to alter the library if they have the required permission, but do not have file path access to any folder the server can access.
84
+
Specifies the content of the package as a hex literal, similar to assemblies.
85
+
86
+
This option is useful if you have the required permission to alter a library, but file access on the server is restricted and you cannot save the contents to a path the server can access.
87
+
88
+
Instead, you can pass the package contents as a variable in binary format.
84
89
85
90
**PLATFORM = WINDOWS**
86
91
@@ -90,39 +95,34 @@ Specifies the platform for the content of the library. This value is required wh
90
95
91
96
For the R language, packages must be prepared in the form of zipped archive files with the .ZIP extension for Windows. Currently, only the Windows platform is supported.
92
97
93
-
The `ALTER EXTERNAL LIBRARY` statement only uploads the library bits to the database. The modified library is not actually installed until a user runs an external script afterwards, by executing [sp_execute_external_script (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-execute-external-script-transact-sql.md).
98
+
The `ALTER EXTERNAL LIBRARY` statement only uploads the library bits to the database. The modified library is installed when a user runs code in [sp_execute_external_script (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-execute-external-script-transact-sql.md) that calls the library.
94
99
95
100
## Permissions
96
101
97
102
Requires the `ALTER ANY EXTERNAL LIBRARY` permission. Users who created an external library, can alter that external library.
98
103
99
104
## Examples
100
105
101
-
The following examples modifies an external library called customPackage.
106
+
The following examples modifies an external library called `customPackage`.
102
107
103
108
### A. Replace the contents of a library using a file
104
109
105
-
The following example modifies an external library called customPackage, using a zipped file containing the updated bits.
110
+
The following example modifies an external library called `customPackage`, using a zipped file containing the updated bits.
0 commit comments