mirror of
https://github.com/Microsoft/sql-server-samples.git
synced 2025-12-08 14:58:54 +00:00
updated getting started samples
This commit is contained in:
+5
-5
@@ -1,4 +1,9 @@
|
||||
|
||||
|
||||
|
||||
# Define the connection string
|
||||
connStr <- paste("Driver=SQL Server;Server=", "MyServer", ";Database=", "tpcx1b", ";Trusted_Connection=true;", sep = "");
|
||||
|
||||
# Input Query
|
||||
input_query <- "
|
||||
SELECT
|
||||
@@ -35,10 +40,6 @@ FROM
|
||||
GROUP BY sr_customer_sk
|
||||
) returned ON ss_customer_sk=sr_customer_sk
|
||||
"
|
||||
|
||||
# Define the connection string
|
||||
connStr <- paste("Driver=SQL Server;Server=", "NELLIELAPTOP", ";Database=", "tpcx1b", ";Trusted_Connection=true;", sep = "");
|
||||
|
||||
# Input customer data that needs to be classified
|
||||
customer_returns <- RxSqlServerData(sqlQuery = input_query,
|
||||
colClasses = c(customer = "numeric", orderRatio = "numeric", itemsRatio = "numeric", monetaryRatio = "numeric", frequency = "numeric"),
|
||||
@@ -56,7 +57,6 @@ head(customer_data, n = 5);
|
||||
wss <- (nrow(customer_data) - 1) * sum(apply(customer_data, 2, var))
|
||||
for (i in 2:20) {
|
||||
xt = kmeans(customer_data, centers = i)
|
||||
print(xt$ifault)
|
||||
wss[i] <- sum(kms = kmeans(customer_data, centers = i)$withinss)
|
||||
}
|
||||
plot(1:20, wss, type = "b", xlab = "Number of Clusters", ylab = "Within groups sum of squares")
|
||||
@@ -0,0 +1,70 @@
|
||||
# Build a predictive model with SQL Server R Services
|
||||
|
||||
This sample provides custom reports for SQL Server R Services that can be viewed from SQL Server Management Studio. The reports can be used to view configuration information, resource usage, execution statistics, active sessions and other information about R Services.
|
||||
|
||||
### Contents
|
||||
|
||||
[About this sample](#about-this-sample)<br/>
|
||||
[Before you begin](#before-you-begin)<br/>
|
||||
[Sample details](#sample-details)<br/>
|
||||
[Related links](#related-links)<br/>
|
||||
|
||||
|
||||
<a name=about-this-sample></a>
|
||||
|
||||
## About this sample
|
||||
|
||||
Predictive modeling is a powerful way to add intelligence to your application. It enables applications to predict outcomes against new data.
|
||||
The act of incorporating predictive analytics into your applications involves two major phases:
|
||||
model training and model operationalization.
|
||||
|
||||
In this sample, you will learn how to create a predictive model in R and operationalize it with SQL Server 2016.
|
||||
|
||||
Follow the step by step tutorial [here](http://aka.ms/sqldev/R) to walk through this sample.
|
||||
|
||||
<!-- Delete the ones that don't apply -->
|
||||
- **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
|
||||
|
||||
<a name=before-you-begin></a>
|
||||
|
||||
## Before you begin
|
||||
|
||||
To run this sample, you need the following prerequisites.
|
||||
Section 1 in the [tutorial](http://aka.ms/sqldev/R) covers all prerequisites.
|
||||
|
||||
**Software prerequisites:**
|
||||
|
||||
<!-- Examples -->
|
||||
1. SQL Server 2016 (or higher) with R Services installed
|
||||
2. SQL Server Management Studio
|
||||
3. R IDE Tool like Visual Studio
|
||||
|
||||
|
||||
<a name=sample-details></a>
|
||||
## Sample Details
|
||||
|
||||
### PredictiveModel.R
|
||||
|
||||
The R script that generates a predictive model and uses it to predict rental counts
|
||||
|
||||
### PredictiveModel.SQL
|
||||
|
||||
Takes the R code in PredictiveModel.R and uses it inside SQL Server. Creating stored procedures for training and prediction.
|
||||
|
||||
|
||||
|
||||
<a name=related-links></a>
|
||||
|
||||
## Related Links
|
||||
<!-- Links to more articles. Remember to delete "en-us" from the link path. -->
|
||||
|
||||
For additional content, see these articles:
|
||||
|
||||
[SQL Server R Services - Upgrade and Installation FAQ](https://msdn.microsoft.com/en-us/library/mt653951.aspx)
|
||||
|
||||
[Other SQL Server R Services Tutorials](https://msdn.microsoft.com/en-us/library/mt591993.aspx)
|
||||
@@ -0,0 +1,70 @@
|
||||
# Build a predictive model with SQL Server R Services
|
||||
|
||||
This sample provides custom reports for SQL Server R Services that can be viewed from SQL Server Management Studio. The reports can be used to view configuration information, resource usage, execution statistics, active sessions and other information about R Services.
|
||||
|
||||
### Contents
|
||||
|
||||
[About this sample](#about-this-sample)<br/>
|
||||
[Before you begin](#before-you-begin)<br/>
|
||||
[Sample details](#sample-details)<br/>
|
||||
[Related links](#related-links)<br/>
|
||||
|
||||
|
||||
<a name=about-this-sample></a>
|
||||
|
||||
## About this sample
|
||||
|
||||
Predictive modeling is a powerful way to add intelligence to your application. It enables applications to predict outcomes against new data.
|
||||
The act of incorporating predictive analytics into your applications involves two major phases:
|
||||
model training and model operationalization.
|
||||
|
||||
In this sample, you will learn how to create a predictive model in R and operationalize it with SQL Server 2016.
|
||||
|
||||
Follow the step by step tutorial [here](http://aka.ms/sqldev/R) to walk through this sample.
|
||||
|
||||
<!-- Delete the ones that don't apply -->
|
||||
- **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
|
||||
|
||||
<a name=before-you-begin></a>
|
||||
|
||||
## Before you begin
|
||||
|
||||
To run this sample, you need the following prerequisites.
|
||||
Section 1 in the [tutorial](http://aka.ms/sqldev/R) covers all prerequisites.
|
||||
|
||||
**Software prerequisites:**
|
||||
|
||||
<!-- Examples -->
|
||||
1. SQL Server 2016 (or higher) with R Services installed
|
||||
2. SQL Server Management Studio
|
||||
3. R IDE Tool like Visual Studio
|
||||
|
||||
|
||||
<a name=sample-details></a>
|
||||
## Sample Details
|
||||
|
||||
### PredictiveModel.R
|
||||
|
||||
The R script that generates a predictive model and uses it to predict rental counts
|
||||
|
||||
### PredictiveModel.SQL
|
||||
|
||||
Takes the R code in PredictiveModel.R and uses it inside SQL Server. Creating stored procedures for training and prediction.
|
||||
|
||||
|
||||
|
||||
<a name=related-links></a>
|
||||
|
||||
## Related Links
|
||||
<!-- Links to more articles. Remember to delete "en-us" from the link path. -->
|
||||
|
||||
For additional content, see these articles:
|
||||
|
||||
[SQL Server R Services - Upgrade and Installation FAQ](https://msdn.microsoft.com/en-us/library/mt653951.aspx)
|
||||
|
||||
[Other SQL Server R Services Tutorials](https://msdn.microsoft.com/en-us/library/mt591993.aspx)
|
||||
Reference in New Issue
Block a user