diff --git a/samples/demos/mssqltiger/LQS/Live Query Stats - Activity Monitor.sql b/samples/demos/LQS/Live Query Stats - Activity Monitor.sql similarity index 97% rename from samples/demos/mssqltiger/LQS/Live Query Stats - Activity Monitor.sql rename to samples/demos/LQS/Live Query Stats - Activity Monitor.sql index b9d759d4..e7805031 100644 --- a/samples/demos/mssqltiger/LQS/Live Query Stats - Activity Monitor.sql +++ b/samples/demos/LQS/Live Query Stats - Activity Monitor.sql @@ -59,4 +59,4 @@ GO INNER JOIN Person.Person AS p ON h.CustomerID = p.BusinessEntityID INNER JOIN Production.Product AS pr ON d.ProductID = pr.ProductID ) SELECT * FROM Prices; -GO \ No newline at end of file +GO diff --git a/samples/demos/mssqltiger/LQS/Live Query Stats - Own Session.sql b/samples/demos/LQS/Live Query Stats - Own Session.sql similarity index 97% rename from samples/demos/mssqltiger/LQS/Live Query Stats - Own Session.sql rename to samples/demos/LQS/Live Query Stats - Own Session.sql index 1c6e0b65..c0a6a749 100644 --- a/samples/demos/mssqltiger/LQS/Live Query Stats - Own Session.sql +++ b/samples/demos/LQS/Live Query Stats - Own Session.sql @@ -58,4 +58,4 @@ GO INNER JOIN Person.Person AS p ON h.CustomerID = p.BusinessEntityID INNER JOIN Production.Product AS pr ON d.ProductID = pr.ProductID ) SELECT * FROM Prices; -GO \ No newline at end of file +GO diff --git a/samples/demos/mssqltiger/LQS/README.md b/samples/demos/LQS/README.md similarity index 100% rename from samples/demos/mssqltiger/LQS/README.md rename to samples/demos/LQS/README.md diff --git a/samples/demos/mssqltiger/Plan-Comparison/Inside-Query-Store/QueryStoreSimpleDemo.exe b/samples/demos/Plan-Comparison/Inside-Query-Store/QueryStoreSimpleDemo.exe similarity index 100% rename from samples/demos/mssqltiger/Plan-Comparison/Inside-Query-Store/QueryStoreSimpleDemo.exe rename to samples/demos/Plan-Comparison/Inside-Query-Store/QueryStoreSimpleDemo.exe diff --git a/samples/demos/mssqltiger/Plan-Comparison/Inside-Query-Store/QueryStoreTest.bacpac b/samples/demos/Plan-Comparison/Inside-Query-Store/QueryStoreTest.bacpac similarity index 100% rename from samples/demos/mssqltiger/Plan-Comparison/Inside-Query-Store/QueryStoreTest.bacpac rename to samples/demos/Plan-Comparison/Inside-Query-Store/QueryStoreTest.bacpac diff --git a/samples/demos/mssqltiger/Plan-Comparison/Inside-Query-Store/README.md b/samples/demos/Plan-Comparison/Inside-Query-Store/README.md similarity index 100% rename from samples/demos/mssqltiger/Plan-Comparison/Inside-Query-Store/README.md rename to samples/demos/Plan-Comparison/Inside-Query-Store/README.md diff --git a/samples/demos/Plan-Comparison/Offline/Compare1_Plan1_Slow.sqlplan b/samples/demos/Plan-Comparison/Offline/Compare1_Plan1_Slow.sqlplan new file mode 100644 index 00000000..bdd4b967 --- /dev/null +++ b/samples/demos/Plan-Comparison/Offline/Compare1_Plan1_Slow.sqlplan @@ -0,0 +1,1074 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/demos/Plan-Comparison/Offline/Compare1_Plan2_Fast.sqlplan b/samples/demos/Plan-Comparison/Offline/Compare1_Plan2_Fast.sqlplan new file mode 100644 index 00000000..8424613f --- /dev/null +++ b/samples/demos/Plan-Comparison/Offline/Compare1_Plan2_Fast.sqlplan @@ -0,0 +1,1015 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/demos/mssqltiger/Plan-Comparison/Offline/README.md b/samples/demos/Plan-Comparison/Offline/README.md similarity index 100% rename from samples/demos/mssqltiger/Plan-Comparison/Offline/README.md rename to samples/demos/Plan-Comparison/Offline/README.md diff --git a/samples/demos/mssqltiger/Showplan/HashWarning.sql b/samples/demos/Showplan/HashWarning.sql similarity index 89% rename from samples/demos/mssqltiger/Showplan/HashWarning.sql rename to samples/demos/Showplan/HashWarning.sql index 3457e005..e4dec4a4 100644 --- a/samples/demos/mssqltiger/Showplan/HashWarning.sql +++ b/samples/demos/Showplan/HashWarning.sql @@ -30,7 +30,7 @@ GO -- Get Actual Execution Plan --- Execute the stored procedure first with parameter value WA which will select 1% of data. +-- Execute the stored procedure first with parameter value ‘WA’ – which will select 1% of data. DBCC FREEPROCCACHE GO EXEC CustomersByState 'WA' @@ -49,4 +49,4 @@ it is split into sub-partitions, which are also processed separately. This splitting process continues until each partition fits into available memory or until the maximum recursion level is reached. In this case it stopped at level 1. -*/ \ No newline at end of file +*/ diff --git a/samples/demos/mssqltiger/Showplan/MemoryGrant_Warning.sql b/samples/demos/Showplan/MemoryGrant_Warning.sql similarity index 96% rename from samples/demos/mssqltiger/Showplan/MemoryGrant_Warning.sql rename to samples/demos/Showplan/MemoryGrant_Warning.sql index 7c0a2853..58f283cb 100644 --- a/samples/demos/mssqltiger/Showplan/MemoryGrant_Warning.sql +++ b/samples/demos/Showplan/MemoryGrant_Warning.sql @@ -18,4 +18,4 @@ GO In SELECT node properties: MaxQueryMemory for maximum query memory grant under RG MAX_MEMORY_PERCENT hint MaxCompileMemory for maximum query optimizer memory in KB during compile under RG -*/ \ No newline at end of file +*/ diff --git a/samples/demos/mssqltiger/Showplan/MemoryGrant_Warning_Setup.sql b/samples/demos/Showplan/MemoryGrant_Warning_Setup.sql similarity index 100% rename from samples/demos/mssqltiger/Showplan/MemoryGrant_Warning_Setup.sql rename to samples/demos/Showplan/MemoryGrant_Warning_Setup.sql diff --git a/samples/demos/mssqltiger/Showplan/README.md b/samples/demos/Showplan/README.md similarity index 100% rename from samples/demos/mssqltiger/Showplan/README.md rename to samples/demos/Showplan/README.md diff --git a/samples/demos/mssqltiger/Showplan/SortWarning.sql b/samples/demos/Showplan/SortWarning.sql similarity index 94% rename from samples/demos/mssqltiger/Showplan/SortWarning.sql rename to samples/demos/Showplan/SortWarning.sql index b16479da..7027ed09 100644 --- a/samples/demos/mssqltiger/Showplan/SortWarning.sql +++ b/samples/demos/Showplan/SortWarning.sql @@ -18,4 +18,4 @@ GO /* Observe the type of Spill = 1 Means one pass over the data was enough to complete the sort in the Worktable -*/ \ No newline at end of file +*/ diff --git a/samples/demos/BelgradeProductCatalogDemo/.gitignore b/samples/demos/belgrade-product-catalog-demo/.gitignore similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/.gitignore rename to samples/demos/belgrade-product-catalog-demo/.gitignore diff --git a/samples/demos/BelgradeProductCatalogDemo/Controllers/CompanyController.cs b/samples/demos/belgrade-product-catalog-demo/Controllers/CompanyController.cs similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/Controllers/CompanyController.cs rename to samples/demos/belgrade-product-catalog-demo/Controllers/CompanyController.cs diff --git a/samples/demos/BelgradeProductCatalogDemo/Controllers/ProductController.cs b/samples/demos/belgrade-product-catalog-demo/Controllers/ProductController.cs similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/Controllers/ProductController.cs rename to samples/demos/belgrade-product-catalog-demo/Controllers/ProductController.cs diff --git a/samples/demos/BelgradeProductCatalogDemo/ProductCatalog.xproj b/samples/demos/belgrade-product-catalog-demo/ProductCatalog.xproj similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/ProductCatalog.xproj rename to samples/demos/belgrade-product-catalog-demo/ProductCatalog.xproj diff --git a/samples/demos/BelgradeProductCatalogDemo/Program.cs b/samples/demos/belgrade-product-catalog-demo/Program.cs similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/Program.cs rename to samples/demos/belgrade-product-catalog-demo/Program.cs diff --git a/samples/demos/BelgradeProductCatalogDemo/Properties/launchSettings.json b/samples/demos/belgrade-product-catalog-demo/Properties/launchSettings.json similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/Properties/launchSettings.json rename to samples/demos/belgrade-product-catalog-demo/Properties/launchSettings.json diff --git a/samples/demos/BelgradeProductCatalogDemo/README.md b/samples/demos/belgrade-product-catalog-demo/README.md similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/README.md rename to samples/demos/belgrade-product-catalog-demo/README.md diff --git a/samples/demos/BelgradeProductCatalogDemo/Startup.cs b/samples/demos/belgrade-product-catalog-demo/Startup.cs similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/Startup.cs rename to samples/demos/belgrade-product-catalog-demo/Startup.cs diff --git a/samples/demos/BelgradeProductCatalogDemo/app.config b/samples/demos/belgrade-product-catalog-demo/app.config similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/app.config rename to samples/demos/belgrade-product-catalog-demo/app.config diff --git a/samples/demos/BelgradeProductCatalogDemo/appsettings.json b/samples/demos/belgrade-product-catalog-demo/appsettings.json similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/appsettings.json rename to samples/demos/belgrade-product-catalog-demo/appsettings.json diff --git a/samples/demos/BelgradeProductCatalogDemo/project.json b/samples/demos/belgrade-product-catalog-demo/project.json similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/project.json rename to samples/demos/belgrade-product-catalog-demo/project.json diff --git a/samples/demos/BelgradeProductCatalogDemo/sql-scripts/0 cleanup.sql b/samples/demos/belgrade-product-catalog-demo/sql-scripts/0 cleanup.sql similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/sql-scripts/0 cleanup.sql rename to samples/demos/belgrade-product-catalog-demo/sql-scripts/0 cleanup.sql diff --git a/samples/demos/BelgradeProductCatalogDemo/sql-scripts/1 setup.sql b/samples/demos/belgrade-product-catalog-demo/sql-scripts/1 setup.sql similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/sql-scripts/1 setup.sql rename to samples/demos/belgrade-product-catalog-demo/sql-scripts/1 setup.sql diff --git a/samples/demos/BelgradeProductCatalogDemo/sql-scripts/2 json.sql b/samples/demos/belgrade-product-catalog-demo/sql-scripts/2 json.sql similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/sql-scripts/2 json.sql rename to samples/demos/belgrade-product-catalog-demo/sql-scripts/2 json.sql diff --git a/samples/demos/BelgradeProductCatalogDemo/sql-scripts/3 setup-temporal.sql b/samples/demos/belgrade-product-catalog-demo/sql-scripts/3 setup-temporal.sql similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/sql-scripts/3 setup-temporal.sql rename to samples/demos/belgrade-product-catalog-demo/sql-scripts/3 setup-temporal.sql diff --git a/samples/demos/BelgradeProductCatalogDemo/sql-scripts/4 temporal.sql b/samples/demos/belgrade-product-catalog-demo/sql-scripts/4 temporal.sql similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/sql-scripts/4 temporal.sql rename to samples/demos/belgrade-product-catalog-demo/sql-scripts/4 temporal.sql diff --git a/samples/demos/BelgradeProductCatalogDemo/sql-scripts/5 data-masking.sql b/samples/demos/belgrade-product-catalog-demo/sql-scripts/5 data-masking.sql similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/sql-scripts/5 data-masking.sql rename to samples/demos/belgrade-product-catalog-demo/sql-scripts/5 data-masking.sql diff --git a/samples/demos/BelgradeProductCatalogDemo/sql-scripts/6 rls.sql b/samples/demos/belgrade-product-catalog-demo/sql-scripts/6 rls.sql similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/sql-scripts/6 rls.sql rename to samples/demos/belgrade-product-catalog-demo/sql-scripts/6 rls.sql diff --git a/samples/demos/BelgradeProductCatalogDemo/sql-scripts/7. xtp.sql b/samples/demos/belgrade-product-catalog-demo/sql-scripts/7. xtp.sql similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/sql-scripts/7. xtp.sql rename to samples/demos/belgrade-product-catalog-demo/sql-scripts/7. xtp.sql diff --git a/samples/demos/BelgradeProductCatalogDemo/sql-scripts/A1 fraud-detection.sql b/samples/demos/belgrade-product-catalog-demo/sql-scripts/A1 fraud-detection.sql similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/sql-scripts/A1 fraud-detection.sql rename to samples/demos/belgrade-product-catalog-demo/sql-scripts/A1 fraud-detection.sql diff --git a/samples/demos/BelgradeProductCatalogDemo/sql-scripts/A2 compare-products.sql b/samples/demos/belgrade-product-catalog-demo/sql-scripts/A2 compare-products.sql similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/sql-scripts/A2 compare-products.sql rename to samples/demos/belgrade-product-catalog-demo/sql-scripts/A2 compare-products.sql diff --git a/samples/demos/BelgradeProductCatalogDemo/sql-scripts/A3 setup-temporal-3-part-name.sql b/samples/demos/belgrade-product-catalog-demo/sql-scripts/A3 setup-temporal-3-part-name.sql similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/sql-scripts/A3 setup-temporal-3-part-name.sql rename to samples/demos/belgrade-product-catalog-demo/sql-scripts/A3 setup-temporal-3-part-name.sql diff --git a/samples/demos/BelgradeProductCatalogDemo/web.config b/samples/demos/belgrade-product-catalog-demo/web.config similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/web.config rename to samples/demos/belgrade-product-catalog-demo/web.config diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/favicon.ico b/samples/demos/belgrade-product-catalog-demo/wwwroot/favicon.ico similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/favicon.ico rename to samples/demos/belgrade-product-catalog-demo/wwwroot/favicon.ico diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/index.html b/samples/demos/belgrade-product-catalog-demo/wwwroot/index.html similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/index.html rename to samples/demos/belgrade-product-catalog-demo/wwwroot/index.html diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/Bootstrap-3.3.5/fonts/glyphicons-halflings-regular.eot b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/Bootstrap-3.3.5/fonts/glyphicons-halflings-regular.eot similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/Bootstrap-3.3.5/fonts/glyphicons-halflings-regular.eot rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/Bootstrap-3.3.5/fonts/glyphicons-halflings-regular.eot diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/Bootstrap-3.3.5/fonts/glyphicons-halflings-regular.svg b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/Bootstrap-3.3.5/fonts/glyphicons-halflings-regular.svg similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/Bootstrap-3.3.5/fonts/glyphicons-halflings-regular.svg rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/Bootstrap-3.3.5/fonts/glyphicons-halflings-regular.svg diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/Bootstrap-3.3.5/fonts/glyphicons-halflings-regular.ttf b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/Bootstrap-3.3.5/fonts/glyphicons-halflings-regular.ttf similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/Bootstrap-3.3.5/fonts/glyphicons-halflings-regular.ttf rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/Bootstrap-3.3.5/fonts/glyphicons-halflings-regular.ttf diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/Bootstrap-3.3.5/fonts/glyphicons-halflings-regular.woff b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/Bootstrap-3.3.5/fonts/glyphicons-halflings-regular.woff similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/Bootstrap-3.3.5/fonts/glyphicons-halflings-regular.woff rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/Bootstrap-3.3.5/fonts/glyphicons-halflings-regular.woff diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/Bootstrap-3.3.5/fonts/glyphicons-halflings-regular.woff2 b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/Bootstrap-3.3.5/fonts/glyphicons-halflings-regular.woff2 similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/Bootstrap-3.3.5/fonts/glyphicons-halflings-regular.woff2 rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/Bootstrap-3.3.5/fonts/glyphicons-halflings-regular.woff2 diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/Bootstrap.css b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/Bootstrap.css similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/Bootstrap.css rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/Bootstrap.css diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/bootstrap-slider.css b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/bootstrap-slider.css similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/bootstrap-slider.css rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/bootstrap-slider.css diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/dataTables.bootstrap.css b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/dataTables.bootstrap.css similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/dataTables.bootstrap.css rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/dataTables.bootstrap.css diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/images/ui-bg_glass_55_fbf9ee_1x400.png b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/images/ui-bg_glass_55_fbf9ee_1x400.png similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/images/ui-bg_glass_55_fbf9ee_1x400.png rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/images/ui-bg_glass_55_fbf9ee_1x400.png diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/images/ui-bg_glass_65_ffffff_1x400.png b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/images/ui-bg_glass_65_ffffff_1x400.png similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/images/ui-bg_glass_65_ffffff_1x400.png rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/images/ui-bg_glass_65_ffffff_1x400.png diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/images/ui-bg_glass_75_dadada_1x400.png b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/images/ui-bg_glass_75_dadada_1x400.png similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/images/ui-bg_glass_75_dadada_1x400.png rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/images/ui-bg_glass_75_dadada_1x400.png diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/images/ui-bg_glass_75_e6e6e6_1x400.png b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/images/ui-bg_glass_75_e6e6e6_1x400.png similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/images/ui-bg_glass_75_e6e6e6_1x400.png rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/images/ui-bg_glass_75_e6e6e6_1x400.png diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/images/ui-bg_glass_95_fef1ec_1x400.png b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/images/ui-bg_glass_95_fef1ec_1x400.png similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/images/ui-bg_glass_95_fef1ec_1x400.png rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/images/ui-bg_glass_95_fef1ec_1x400.png diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/images/ui-bg_highlight-soft_75_cccccc_1x100.png b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/images/ui-bg_highlight-soft_75_cccccc_1x100.png similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/images/ui-bg_highlight-soft_75_cccccc_1x100.png rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/images/ui-bg_highlight-soft_75_cccccc_1x100.png diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/images/ui-icons_222222_256x240.png b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/images/ui-icons_222222_256x240.png similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/images/ui-icons_222222_256x240.png rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/images/ui-icons_222222_256x240.png diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/images/ui-icons_2e83ff_256x240.png b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/images/ui-icons_2e83ff_256x240.png similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/images/ui-icons_2e83ff_256x240.png rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/images/ui-icons_2e83ff_256x240.png diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/images/ui-icons_454545_256x240.png b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/images/ui-icons_454545_256x240.png similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/images/ui-icons_454545_256x240.png rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/images/ui-icons_454545_256x240.png diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/images/ui-icons_888888_256x240.png b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/images/ui-icons_888888_256x240.png similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/images/ui-icons_888888_256x240.png rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/images/ui-icons_888888_256x240.png diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/images/ui-icons_cd0a0a_256x240.png b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/images/ui-icons_cd0a0a_256x240.png similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/images/ui-icons_cd0a0a_256x240.png rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/images/ui-icons_cd0a0a_256x240.png diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/jquery-ui.css b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/jquery-ui.css similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/jquery-ui.css rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/jquery-ui.css diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/jquery-ui.min.css b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/jquery-ui.min.css similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/jquery-ui.min.css rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/jquery-ui.min.css diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/jquery-ui.structure.css b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/jquery-ui.structure.css similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/jquery-ui.structure.css rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/jquery-ui.structure.css diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/jquery-ui.structure.min.css b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/jquery-ui.structure.min.css similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/jquery-ui.structure.min.css rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/jquery-ui.structure.min.css diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/jquery-ui.theme.css b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/jquery-ui.theme.css similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/jquery-ui.theme.css rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/jquery-ui.theme.css diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/jquery-ui.theme.min.css b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/jquery-ui.theme.min.css similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/jquery-ui/jquery-ui.theme.min.css rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/jquery-ui/jquery-ui.theme.min.css diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/products.css b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/products.css similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/products.css rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/products.css diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/toastr.min.css b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/toastr.min.css similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/css/toastr.min.css rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/css/toastr.min.css diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/images/Sorting icons.psd b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/images/Sorting icons.psd similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/images/Sorting icons.psd rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/images/Sorting icons.psd diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/images/details_close.png b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/images/details_close.png similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/images/details_close.png rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/images/details_close.png diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/images/details_open.png b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/images/details_open.png similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/images/details_open.png rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/images/details_open.png diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/images/favicon.ico b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/images/favicon.ico similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/images/favicon.ico rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/images/favicon.ico diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/images/sort_asc.png b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/images/sort_asc.png similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/images/sort_asc.png rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/images/sort_asc.png diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/images/sort_asc_disabled.png b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/images/sort_asc_disabled.png similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/images/sort_asc_disabled.png rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/images/sort_asc_disabled.png diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/images/sort_both.png b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/images/sort_both.png similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/images/sort_both.png rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/images/sort_both.png diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/images/sort_desc.png b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/images/sort_desc.png similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/images/sort_desc.png rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/images/sort_desc.png diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/images/sort_desc_disabled.png b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/images/sort_desc_disabled.png similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/images/sort_desc_disabled.png rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/images/sort_desc_disabled.png diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/js/lib/Bootstrap.js b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/js/lib/Bootstrap.js similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/js/lib/Bootstrap.js rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/js/lib/Bootstrap.js diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/js/lib/jquery-ui.js b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/js/lib/jquery-ui.js similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/js/lib/jquery-ui.js rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/js/lib/jquery-ui.js diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/js/lib/jquery.dataTables.Bootstrap.js b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/js/lib/jquery.dataTables.Bootstrap.js similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/js/lib/jquery.dataTables.Bootstrap.js rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/js/lib/jquery.dataTables.Bootstrap.js diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/js/lib/jquery.dataTables.js b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/js/lib/jquery.dataTables.js similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/js/lib/jquery.dataTables.js rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/js/lib/jquery.dataTables.js diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/js/lib/jquery.html-template.js b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/js/lib/jquery.html-template.js similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/js/lib/jquery.html-template.js rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/js/lib/jquery.html-template.js diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/js/lib/jquery.js b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/js/lib/jquery.js similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/js/lib/jquery.js rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/js/lib/jquery.js diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/js/lib/jquery.serializejson.js b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/js/lib/jquery.serializejson.js similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/js/lib/jquery.serializejson.js rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/js/lib/jquery.serializejson.js diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/js/lib/toastr.min.js b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/js/lib/toastr.min.js similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/js/lib/toastr.min.js rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/js/lib/toastr.min.js diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/js/products-temporal.js b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/js/products-temporal.js similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/js/products-temporal.js rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/js/products-temporal.js diff --git a/samples/demos/BelgradeProductCatalogDemo/wwwroot/media/js/products.js b/samples/demos/belgrade-product-catalog-demo/wwwroot/media/js/products.js similarity index 100% rename from samples/demos/BelgradeProductCatalogDemo/wwwroot/media/js/products.js rename to samples/demos/belgrade-product-catalog-demo/wwwroot/media/js/products.js diff --git a/samples/demos/mssqltiger/Plan-Comparison/Offline/Compare1_Plan1_Slow.sqlplan b/samples/demos/mssqltiger/Plan-Comparison/Offline/Compare1_Plan1_Slow.sqlplan deleted file mode 100644 index 67774d78..00000000 Binary files a/samples/demos/mssqltiger/Plan-Comparison/Offline/Compare1_Plan1_Slow.sqlplan and /dev/null differ diff --git a/samples/demos/mssqltiger/Plan-Comparison/Offline/Compare1_Plan2_Fast.sqlplan b/samples/demos/mssqltiger/Plan-Comparison/Offline/Compare1_Plan2_Fast.sqlplan deleted file mode 100644 index 86e9b888..00000000 Binary files a/samples/demos/mssqltiger/Plan-Comparison/Offline/Compare1_Plan2_Fast.sqlplan and /dev/null differ diff --git a/samples/demos/mssqltiger/README.md b/samples/demos/mssqltiger/README.md deleted file mode 100644 index 13b9db7a..00000000 --- a/samples/demos/mssqltiger/README.md +++ /dev/null @@ -1,2 +0,0 @@ -

MSSQLTIGER Demos

-This is a repository of the scripts used during demos that are delivered by the SQL Server Tiger team. diff --git a/samples/demos/mssqltiger/xEvents/HashWarning.sql b/samples/demos/xEvents/HashWarning.sql similarity index 93% rename from samples/demos/mssqltiger/xEvents/HashWarning.sql rename to samples/demos/xEvents/HashWarning.sql index 44744d99..559e8b37 100644 --- a/samples/demos/mssqltiger/xEvents/HashWarning.sql +++ b/samples/demos/xEvents/HashWarning.sql @@ -42,7 +42,7 @@ ADD TARGET package0.event_file(SET filename=N'C:\IP\Tiger\TR23\Demos\Demo 1.1 - WITH (MAX_MEMORY=4096 KB,EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,MAX_DISPATCH_LATENCY=30 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=NONE,TRACK_CAUSALITY=OFF,STARTUP_STATE=OFF) GO ---Execute the stored procedure first with parameter value WA which will select 1% of data. +--Execute the stored procedure first with parameter value ‘WA’ – which will select 1% of data. DBCC FREEPROCCACHE GO ALTER EVENT SESSION [HashSpills] ON SERVER STATE = START @@ -65,4 +65,4 @@ it is split into sub-partitions, which are also processed separately. This splitting process continues until each partition fits into available memory or until the maximum recursion level is reached. In this case it stopped at level 1. -*/ \ No newline at end of file +*/ diff --git a/samples/demos/mssqltiger/xEvents/MemoryGrant_XE.sql b/samples/demos/xEvents/MemoryGrant_XE.sql similarity index 100% rename from samples/demos/mssqltiger/xEvents/MemoryGrant_XE.sql rename to samples/demos/xEvents/MemoryGrant_XE.sql diff --git a/samples/demos/mssqltiger/xEvents/MemoryGrant_XE_Setup.sql b/samples/demos/xEvents/MemoryGrant_XE_Setup.sql similarity index 100% rename from samples/demos/mssqltiger/xEvents/MemoryGrant_XE_Setup.sql rename to samples/demos/xEvents/MemoryGrant_XE_Setup.sql diff --git a/samples/demos/mssqltiger/xEvents/PerfStats_XE_Demo.sql b/samples/demos/xEvents/PerfStats_XE_Demo.sql similarity index 94% rename from samples/demos/mssqltiger/xEvents/PerfStats_XE_Demo.sql rename to samples/demos/xEvents/PerfStats_XE_Demo.sql index 8159ee45..60f61c9a 100644 --- a/samples/demos/mssqltiger/xEvents/PerfStats_XE_Demo.sql +++ b/samples/demos/xEvents/PerfStats_XE_Demo.sql @@ -39,4 +39,4 @@ GO -- After running query, get new signed query or query plan hash and run below to see new columns in DMV SELECT * FROM sys.dm_exec_query_stats WHERE CAST(query_hash AS BIGINT) = -5396503127623128976; ---WHERE CAST(query_plan_hash AS BIGINT) = 3230654061787450360 \ No newline at end of file +--WHERE CAST(query_plan_hash AS BIGINT) = 3230654061787450360 diff --git a/samples/demos/mssqltiger/xEvents/README.md b/samples/demos/xEvents/README.md similarity index 100% rename from samples/demos/mssqltiger/xEvents/README.md rename to samples/demos/xEvents/README.md diff --git a/samples/demos/mssqltiger/xEvents/SortWarning.sql b/samples/demos/xEvents/SortWarning.sql similarity index 97% rename from samples/demos/mssqltiger/xEvents/SortWarning.sql rename to samples/demos/xEvents/SortWarning.sql index 9cfa371b..17b8af7e 100644 --- a/samples/demos/mssqltiger/xEvents/SortWarning.sql +++ b/samples/demos/xEvents/SortWarning.sql @@ -30,4 +30,4 @@ GO /* Observe the type of Spill = 1 Means one pass over the data was enough to complete the sort in the Worktable -*/ \ No newline at end of file +*/ diff --git a/samples/features/columnstore/InMemoryColumnstore/hk_cs_dmvs.sql b/samples/features/columnstore/in-memory-columnstore/hk_cs_dmvs.sql similarity index 100% rename from samples/features/columnstore/InMemoryColumnstore/hk_cs_dmvs.sql rename to samples/features/columnstore/in-memory-columnstore/hk_cs_dmvs.sql diff --git a/samples/features/columnstore/InMemoryColumnstore/hk_memory_dmvs.sql b/samples/features/columnstore/in-memory-columnstore/hk_memory_dmvs.sql similarity index 100% rename from samples/features/columnstore/InMemoryColumnstore/hk_memory_dmvs.sql rename to samples/features/columnstore/in-memory-columnstore/hk_memory_dmvs.sql diff --git a/samples/features/columnstore/InMemoryColumnstore/hkcs-demo.sql b/samples/features/columnstore/in-memory-columnstore/hkcs-demo.sql similarity index 100% rename from samples/features/columnstore/InMemoryColumnstore/hkcs-demo.sql rename to samples/features/columnstore/in-memory-columnstore/hkcs-demo.sql diff --git a/samples/features/columnstore/NonclusteredColumnstore/compression-delay-setup.sql b/samples/features/columnstore/nonclustered-columnstore/compression-delay-setup.sql similarity index 100% rename from samples/features/columnstore/NonclusteredColumnstore/compression-delay-setup.sql rename to samples/features/columnstore/nonclustered-columnstore/compression-delay-setup.sql diff --git a/samples/features/columnstore/NonclusteredColumnstore/ncci_demo.sql b/samples/features/columnstore/nonclustered-columnstore/ncci_demo.sql similarity index 100% rename from samples/features/columnstore/NonclusteredColumnstore/ncci_demo.sql rename to samples/features/columnstore/nonclustered-columnstore/ncci_demo.sql diff --git a/samples/features/master-data-services/BusinessRules/BusinessRules.sln b/samples/features/master-data-services/BusinessRules/BusinessRules.sln deleted file mode 100644 index d5ae685f..00000000 --- a/samples/features/master-data-services/BusinessRules/BusinessRules.sln +++ /dev/null @@ -1,22 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.40629.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BusinessRules", "BusinessRules.csproj", "{6F10BF17-E821-41D8-A83A-43787AC9E238}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x86 = Debug|x86 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6F10BF17-E821-41D8-A83A-43787AC9E238}.Debug|x86.ActiveCfg = Debug|x86 - {6F10BF17-E821-41D8-A83A-43787AC9E238}.Debug|x86.Build.0 = Debug|x86 - {6F10BF17-E821-41D8-A83A-43787AC9E238}.Release|x86.ActiveCfg = Release|x86 - {6F10BF17-E821-41D8-A83A-43787AC9E238}.Release|x86.Build.0 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/samples/features/master-data-services/EntityBasedStaging/EntityBasedStaging.sln b/samples/features/master-data-services/EntityBasedStaging/EntityBasedStaging.sln deleted file mode 100644 index f1e8a35b..00000000 --- a/samples/features/master-data-services/EntityBasedStaging/EntityBasedStaging.sln +++ /dev/null @@ -1,22 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.40629.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EntityBasedStaging", "EntityBasedStaging.csproj", "{7FA4CB6A-A741-431D-90FB-CB6D355D3CF5}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x86 = Debug|x86 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {7FA4CB6A-A741-431D-90FB-CB6D355D3CF5}.Debug|x86.ActiveCfg = Debug|x86 - {7FA4CB6A-A741-431D-90FB-CB6D355D3CF5}.Debug|x86.Build.0 = Debug|x86 - {7FA4CB6A-A741-431D-90FB-CB6D355D3CF5}.Release|x86.ActiveCfg = Release|x86 - {7FA4CB6A-A741-431D-90FB-CB6D355D3CF5}.Release|x86.Build.0 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/samples/features/master-data-services/MasterData/MasterData.sln b/samples/features/master-data-services/MasterData/MasterData.sln deleted file mode 100644 index 311432b3..00000000 --- a/samples/features/master-data-services/MasterData/MasterData.sln +++ /dev/null @@ -1,22 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.40629.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MasterData", "MasterData.csproj", "{BCEB2125-EA3D-4F38-952E-6B409AADFC00}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x86 = Debug|x86 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BCEB2125-EA3D-4F38-952E-6B409AADFC00}.Debug|x86.ActiveCfg = Debug|x86 - {BCEB2125-EA3D-4F38-952E-6B409AADFC00}.Debug|x86.Build.0 = Debug|x86 - {BCEB2125-EA3D-4F38-952E-6B409AADFC00}.Release|x86.ActiveCfg = Release|x86 - {BCEB2125-EA3D-4F38-952E-6B409AADFC00}.Release|x86.Build.0 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/samples/features/master-data-services/MetaData/Metadata.sln b/samples/features/master-data-services/MetaData/Metadata.sln deleted file mode 100644 index d3ced021..00000000 --- a/samples/features/master-data-services/MetaData/Metadata.sln +++ /dev/null @@ -1,22 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.40629.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Metadata", "Metadata.csproj", "{BCEB2125-EA3D-4F38-952E-6B409AADFC00}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x86 = Debug|x86 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BCEB2125-EA3D-4F38-952E-6B409AADFC00}.Debug|x86.ActiveCfg = Debug|x86 - {BCEB2125-EA3D-4F38-952E-6B409AADFC00}.Debug|x86.Build.0 = Debug|x86 - {BCEB2125-EA3D-4F38-952E-6B409AADFC00}.Release|x86.ActiveCfg = Release|x86 - {BCEB2125-EA3D-4F38-952E-6B409AADFC00}.Release|x86.Build.0 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/samples/features/master-data-services/ModelDeployment/ModelDUtil.sln b/samples/features/master-data-services/ModelDeployment/ModelDUtil.sln deleted file mode 100644 index 9d600c64..00000000 --- a/samples/features/master-data-services/ModelDeployment/ModelDUtil.sln +++ /dev/null @@ -1,22 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.40629.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModelDUtil", "ModelDUtil.csproj", "{E911D29A-5406-4224-86D1-040793262668}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E911D29A-5406-4224-86D1-040793262668}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E911D29A-5406-4224-86D1-040793262668}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E911D29A-5406-4224-86D1-040793262668}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E911D29A-5406-4224-86D1-040793262668}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/samples/features/master-data-services/Security/Security.sln b/samples/features/master-data-services/Security/Security.sln deleted file mode 100644 index b3bb82cb..00000000 --- a/samples/features/master-data-services/Security/Security.sln +++ /dev/null @@ -1,22 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.40629.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Security", "Security.csproj", "{EE9E1B99-CA00-4810-8369-C8FF02468986}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x86 = Debug|x86 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {EE9E1B99-CA00-4810-8369-C8FF02468986}.Debug|x86.ActiveCfg = Debug|x86 - {EE9E1B99-CA00-4810-8369-C8FF02468986}.Debug|x86.Build.0 = Debug|x86 - {EE9E1B99-CA00-4810-8369-C8FF02468986}.Release|x86.ActiveCfg = Release|x86 - {EE9E1B99-CA00-4810-8369-C8FF02468986}.Release|x86.Build.0 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/samples/features/master-data-services/Workflow/Microsoft.MasterDataServices.SharePointWorkflow.sln b/samples/features/master-data-services/Workflow/Microsoft.MasterDataServices.SharePointWorkflow.sln deleted file mode 100644 index 3321a476..00000000 --- a/samples/features/master-data-services/Workflow/Microsoft.MasterDataServices.SharePointWorkflow.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.40629.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.MasterDataServices.SharePointWorkflow", "Microsoft.MasterDataServices.SharePointWorkflow.csproj", "{C51DC0C5-27A0-4210-8286-E16D639028C5}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x86 = Debug|x86 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C51DC0C5-27A0-4210-8286-E16D639028C5}.Debug|x86.ActiveCfg = Debug|Any CPU - {C51DC0C5-27A0-4210-8286-E16D639028C5}.Release|x86.ActiveCfg = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/samples/features/master-data-services/BusinessRules/BusinessRules.csproj b/samples/features/master-data-services/business-rules/BusinessRules.csproj similarity index 100% rename from samples/features/master-data-services/BusinessRules/BusinessRules.csproj rename to samples/features/master-data-services/business-rules/BusinessRules.csproj diff --git a/samples/features/master-data-services/BusinessRules/Program.cs b/samples/features/master-data-services/business-rules/Program.cs similarity index 100% rename from samples/features/master-data-services/BusinessRules/Program.cs rename to samples/features/master-data-services/business-rules/Program.cs diff --git a/samples/features/master-data-services/BusinessRules/Properties/AssemblyInfo.cs b/samples/features/master-data-services/business-rules/Properties/AssemblyInfo.cs similarity index 100% rename from samples/features/master-data-services/BusinessRules/Properties/AssemblyInfo.cs rename to samples/features/master-data-services/business-rules/Properties/AssemblyInfo.cs diff --git a/samples/features/master-data-services/BusinessRules/README.md b/samples/features/master-data-services/business-rules/README.md similarity index 100% rename from samples/features/master-data-services/BusinessRules/README.md rename to samples/features/master-data-services/business-rules/README.md diff --git a/samples/features/master-data-services/BusinessRules/Reference.cs b/samples/features/master-data-services/business-rules/Reference.cs similarity index 100% rename from samples/features/master-data-services/BusinessRules/Reference.cs rename to samples/features/master-data-services/business-rules/Reference.cs diff --git a/samples/features/master-data-services/EntityBasedStaging/EntityBasedStaging.csproj b/samples/features/master-data-services/entity-based-staging/EntityBasedStaging.csproj similarity index 100% rename from samples/features/master-data-services/EntityBasedStaging/EntityBasedStaging.csproj rename to samples/features/master-data-services/entity-based-staging/EntityBasedStaging.csproj diff --git a/samples/features/master-data-services/EntityBasedStaging/Program.cs b/samples/features/master-data-services/entity-based-staging/Program.cs similarity index 100% rename from samples/features/master-data-services/EntityBasedStaging/Program.cs rename to samples/features/master-data-services/entity-based-staging/Program.cs diff --git a/samples/features/master-data-services/EntityBasedStaging/Properties/AssemblyInfo.cs b/samples/features/master-data-services/entity-based-staging/Properties/AssemblyInfo.cs similarity index 100% rename from samples/features/master-data-services/EntityBasedStaging/Properties/AssemblyInfo.cs rename to samples/features/master-data-services/entity-based-staging/Properties/AssemblyInfo.cs diff --git a/samples/features/master-data-services/EntityBasedStaging/README.md b/samples/features/master-data-services/entity-based-staging/README.md similarity index 100% rename from samples/features/master-data-services/EntityBasedStaging/README.md rename to samples/features/master-data-services/entity-based-staging/README.md diff --git a/samples/features/master-data-services/EntityBasedStaging/Reference.cs b/samples/features/master-data-services/entity-based-staging/Reference.cs similarity index 100% rename from samples/features/master-data-services/EntityBasedStaging/Reference.cs rename to samples/features/master-data-services/entity-based-staging/Reference.cs diff --git a/samples/features/master-data-services/MasterData/MasterData.csproj b/samples/features/master-data-services/master-data/MasterData.csproj similarity index 100% rename from samples/features/master-data-services/MasterData/MasterData.csproj rename to samples/features/master-data-services/master-data/MasterData.csproj diff --git a/samples/features/master-data-services/MasterData/Program.cs b/samples/features/master-data-services/master-data/Program.cs similarity index 100% rename from samples/features/master-data-services/MasterData/Program.cs rename to samples/features/master-data-services/master-data/Program.cs diff --git a/samples/features/master-data-services/MasterData/Properties/AssemblyInfo.cs b/samples/features/master-data-services/master-data/Properties/AssemblyInfo.cs similarity index 100% rename from samples/features/master-data-services/MasterData/Properties/AssemblyInfo.cs rename to samples/features/master-data-services/master-data/Properties/AssemblyInfo.cs diff --git a/samples/features/master-data-services/MasterData/README.md b/samples/features/master-data-services/master-data/README.md similarity index 100% rename from samples/features/master-data-services/MasterData/README.md rename to samples/features/master-data-services/master-data/README.md diff --git a/samples/features/master-data-services/MasterData/Reference.cs b/samples/features/master-data-services/master-data/Reference.cs similarity index 100% rename from samples/features/master-data-services/MasterData/Reference.cs rename to samples/features/master-data-services/master-data/Reference.cs diff --git a/samples/features/master-data-services/MetaData/Metadata.csproj b/samples/features/master-data-services/metadata/Metadata.csproj similarity index 100% rename from samples/features/master-data-services/MetaData/Metadata.csproj rename to samples/features/master-data-services/metadata/Metadata.csproj diff --git a/samples/features/master-data-services/MetaData/Program.cs b/samples/features/master-data-services/metadata/Program.cs similarity index 100% rename from samples/features/master-data-services/MetaData/Program.cs rename to samples/features/master-data-services/metadata/Program.cs diff --git a/samples/features/master-data-services/MetaData/Properties/AssemblyInfo.cs b/samples/features/master-data-services/metadata/Properties/AssemblyInfo.cs similarity index 100% rename from samples/features/master-data-services/MetaData/Properties/AssemblyInfo.cs rename to samples/features/master-data-services/metadata/Properties/AssemblyInfo.cs diff --git a/samples/features/master-data-services/MetaData/README.md b/samples/features/master-data-services/metadata/README.md similarity index 100% rename from samples/features/master-data-services/MetaData/README.md rename to samples/features/master-data-services/metadata/README.md diff --git a/samples/features/master-data-services/MetaData/Reference.cs b/samples/features/master-data-services/metadata/Reference.cs similarity index 100% rename from samples/features/master-data-services/MetaData/Reference.cs rename to samples/features/master-data-services/metadata/Reference.cs diff --git a/samples/features/master-data-services/ModelDeployment/ModelDUtil.csproj b/samples/features/master-data-services/model-deployment/ModelDUtil.csproj similarity index 100% rename from samples/features/master-data-services/ModelDeployment/ModelDUtil.csproj rename to samples/features/master-data-services/model-deployment/ModelDUtil.csproj diff --git a/samples/features/master-data-services/ModelDeployment/ModelDUtil.exe.config b/samples/features/master-data-services/model-deployment/ModelDUtil.exe.config similarity index 100% rename from samples/features/master-data-services/ModelDeployment/ModelDUtil.exe.config rename to samples/features/master-data-services/model-deployment/ModelDUtil.exe.config diff --git a/samples/features/master-data-services/ModelDeployment/Modes.cs b/samples/features/master-data-services/model-deployment/Modes.cs similarity index 100% rename from samples/features/master-data-services/ModelDeployment/Modes.cs rename to samples/features/master-data-services/model-deployment/Modes.cs diff --git a/samples/features/master-data-services/ModelDeployment/Program.cs b/samples/features/master-data-services/model-deployment/Program.cs similarity index 100% rename from samples/features/master-data-services/ModelDeployment/Program.cs rename to samples/features/master-data-services/model-deployment/Program.cs diff --git a/samples/features/master-data-services/ModelDeployment/Properties/AssemblyInfo.cs b/samples/features/master-data-services/model-deployment/Properties/AssemblyInfo.cs similarity index 100% rename from samples/features/master-data-services/ModelDeployment/Properties/AssemblyInfo.cs rename to samples/features/master-data-services/model-deployment/Properties/AssemblyInfo.cs diff --git a/samples/features/master-data-services/ModelDeployment/README.md b/samples/features/master-data-services/model-deployment/README.md similarity index 100% rename from samples/features/master-data-services/ModelDeployment/README.md rename to samples/features/master-data-services/model-deployment/README.md diff --git a/samples/features/master-data-services/Security/Program.cs b/samples/features/master-data-services/security/Program.cs similarity index 100% rename from samples/features/master-data-services/Security/Program.cs rename to samples/features/master-data-services/security/Program.cs diff --git a/samples/features/master-data-services/Security/Properties/AssemblyInfo.cs b/samples/features/master-data-services/security/Properties/AssemblyInfo.cs similarity index 100% rename from samples/features/master-data-services/Security/Properties/AssemblyInfo.cs rename to samples/features/master-data-services/security/Properties/AssemblyInfo.cs diff --git a/samples/features/master-data-services/Security/README.md b/samples/features/master-data-services/security/README.md similarity index 100% rename from samples/features/master-data-services/Security/README.md rename to samples/features/master-data-services/security/README.md diff --git a/samples/features/master-data-services/Security/Reference.cs b/samples/features/master-data-services/security/Reference.cs similarity index 100% rename from samples/features/master-data-services/Security/Reference.cs rename to samples/features/master-data-services/security/Reference.cs diff --git a/samples/features/master-data-services/Security/Security.csproj b/samples/features/master-data-services/security/Security.csproj similarity index 100% rename from samples/features/master-data-services/Security/Security.csproj rename to samples/features/master-data-services/security/Security.csproj diff --git a/samples/features/master-data-services/Security/SecurityInformation.cs b/samples/features/master-data-services/security/SecurityInformation.cs similarity index 100% rename from samples/features/master-data-services/Security/SecurityInformation.cs rename to samples/features/master-data-services/security/SecurityInformation.cs diff --git a/samples/features/master-data-services/Workflow/Microsoft.MasterDataServices.SharePointWorkflow.csproj b/samples/features/master-data-services/workflow/Microsoft.MasterDataServices.SharePointWorkflow.csproj similarity index 100% rename from samples/features/master-data-services/Workflow/Microsoft.MasterDataServices.SharePointWorkflow.csproj rename to samples/features/master-data-services/workflow/Microsoft.MasterDataServices.SharePointWorkflow.csproj diff --git a/samples/features/master-data-services/Workflow/Properties/AssemblyInfo.cs b/samples/features/master-data-services/workflow/Properties/AssemblyInfo.cs similarity index 100% rename from samples/features/master-data-services/Workflow/Properties/AssemblyInfo.cs rename to samples/features/master-data-services/workflow/Properties/AssemblyInfo.cs diff --git a/samples/features/master-data-services/Workflow/README.md b/samples/features/master-data-services/workflow/README.md similarity index 100% rename from samples/features/master-data-services/Workflow/README.md rename to samples/features/master-data-services/workflow/README.md diff --git a/samples/features/master-data-services/Workflow/SharePointWorkflowExtender.cs b/samples/features/master-data-services/workflow/SharePointWorkflowExtender.cs similarity index 100% rename from samples/features/master-data-services/Workflow/SharePointWorkflowExtender.cs rename to samples/features/master-data-services/workflow/SharePointWorkflowExtender.cs diff --git a/samples/features/r-services/Getting-Started/Customer-Clustering/Customer Clustering.R b/samples/features/r-services/getting-started/customer-clustering/Customer Clustering.R similarity index 100% rename from samples/features/r-services/Getting-Started/Customer-Clustering/Customer Clustering.R rename to samples/features/r-services/getting-started/customer-clustering/Customer Clustering.R diff --git a/samples/features/r-services/Getting-Started/Customer-Clustering/Customer Clustering.sql b/samples/features/r-services/getting-started/customer-clustering/Customer Clustering.sql similarity index 100% rename from samples/features/r-services/Getting-Started/Customer-Clustering/Customer Clustering.sql rename to samples/features/r-services/getting-started/customer-clustering/Customer Clustering.sql diff --git a/samples/features/r-services/Getting-Started/Customer-Clustering/README.md b/samples/features/r-services/getting-started/customer-clustering/README.md similarity index 100% rename from samples/features/r-services/Getting-Started/Customer-Clustering/README.md rename to samples/features/r-services/getting-started/customer-clustering/README.md diff --git a/samples/features/r-services/Getting-Started/Customer-Clustering/Setup.sql b/samples/features/r-services/getting-started/customer-clustering/Setup.sql similarity index 100% rename from samples/features/r-services/Getting-Started/Customer-Clustering/Setup.sql rename to samples/features/r-services/getting-started/customer-clustering/Setup.sql diff --git a/samples/features/r-services/Getting-Started/Predictive-Modeling/Predictive Model.R b/samples/features/r-services/getting-started/predictive-modeling/Predictive Model.R similarity index 100% rename from samples/features/r-services/Getting-Started/Predictive-Modeling/Predictive Model.R rename to samples/features/r-services/getting-started/predictive-modeling/Predictive Model.R diff --git a/samples/features/r-services/Getting-Started/Predictive-Modeling/Predictive Model.sql b/samples/features/r-services/getting-started/predictive-modeling/Predictive Model.sql similarity index 100% rename from samples/features/r-services/Getting-Started/Predictive-Modeling/Predictive Model.sql rename to samples/features/r-services/getting-started/predictive-modeling/Predictive Model.sql diff --git a/samples/features/r-services/Getting-Started/Predictive-Modeling/README.md b/samples/features/r-services/getting-started/predictive-modeling/README.md similarity index 100% rename from samples/features/r-services/Getting-Started/Predictive-Modeling/README.md rename to samples/features/r-services/getting-started/predictive-modeling/README.md diff --git a/samples/features/r-services/Getting-Started/Predictive-Modeling/Setup.sql b/samples/features/r-services/getting-started/predictive-modeling/Setup.sql similarity index 100% rename from samples/features/r-services/Getting-Started/Predictive-Modeling/Setup.sql rename to samples/features/r-services/getting-started/predictive-modeling/Setup.sql diff --git a/samples/features/r-services/Loan Classification/1 - Create Database.sql b/samples/features/r-services/loan-classification/1 - Create Database.sql similarity index 96% rename from samples/features/r-services/Loan Classification/1 - Create Database.sql rename to samples/features/r-services/loan-classification/1 - Create Database.sql index df882324..05ba8f24 100644 --- a/samples/features/r-services/Loan Classification/1 - Create Database.sql +++ b/samples/features/r-services/loan-classification/1 - Create Database.sql @@ -1,792 +1,792 @@ -USE [master] -GO - -/****** Object: Database [LendingClub] Script Date: 12/29/2016 9:29:37 PM ******/ -CREATE DATABASE [LendingClub] - CONTAINMENT = NONE - ON PRIMARY -( NAME = N'LendingClubData', FILENAME = N'C:\Tiger\DATA\LendingClub.mdf' , SIZE = 19210240KB , MAXSIZE = UNLIMITED, FILEGROWTH = 65536MB ), - FILEGROUP [InMemOLTP] CONTAINS MEMORY_OPTIMIZED_DATA DEFAULT -( NAME = N'InMem', FILENAME = N'C:\Tiger\DATA\InMem' , MAXSIZE = UNLIMITED) - LOG ON -( NAME = N'LendingClubLog', FILENAME = N'C:\Tiger\DATA\LendingClub_log.ldf' , SIZE = 512MB , MAXSIZE = 2048GB , FILEGROWTH = 64MB ) -GO - -ALTER DATABASE [LendingClub] SET COMPATIBILITY_LEVEL = 130 -GO - -ALTER DATABASE [LendingClub] SET ANSI_NULL_DEFAULT OFF -GO - -ALTER DATABASE [LendingClub] SET ANSI_NULLS OFF -GO - -ALTER DATABASE [LendingClub] SET ANSI_PADDING OFF -GO - -ALTER DATABASE [LendingClub] SET ANSI_WARNINGS OFF -GO - -ALTER DATABASE [LendingClub] SET ARITHABORT OFF -GO - -ALTER DATABASE [LendingClub] SET AUTO_CLOSE OFF -GO - -ALTER DATABASE [LendingClub] SET AUTO_SHRINK OFF -GO - -ALTER DATABASE [LendingClub] SET AUTO_UPDATE_STATISTICS ON -GO - -ALTER DATABASE [LendingClub] SET CURSOR_CLOSE_ON_COMMIT OFF -GO - -ALTER DATABASE [LendingClub] SET CURSOR_DEFAULT GLOBAL -GO - -ALTER DATABASE [LendingClub] SET CONCAT_NULL_YIELDS_NULL OFF -GO - -ALTER DATABASE [LendingClub] SET NUMERIC_ROUNDABORT OFF -GO - -ALTER DATABASE [LendingClub] SET QUOTED_IDENTIFIER OFF -GO - -ALTER DATABASE [LendingClub] SET RECURSIVE_TRIGGERS OFF -GO - -ALTER DATABASE [LendingClub] SET ENABLE_BROKER -GO - -ALTER DATABASE [LendingClub] SET AUTO_UPDATE_STATISTICS_ASYNC OFF -GO - -ALTER DATABASE [LendingClub] SET DATE_CORRELATION_OPTIMIZATION OFF -GO - -ALTER DATABASE [LendingClub] SET TRUSTWORTHY OFF -GO - -ALTER DATABASE [LendingClub] SET ALLOW_SNAPSHOT_ISOLATION OFF -GO - -ALTER DATABASE [LendingClub] SET PARAMETERIZATION SIMPLE -GO - -ALTER DATABASE [LendingClub] SET READ_COMMITTED_SNAPSHOT OFF -GO - -ALTER DATABASE [LendingClub] SET HONOR_BROKER_PRIORITY OFF -GO - -ALTER DATABASE [LendingClub] SET RECOVERY SIMPLE -GO - -ALTER DATABASE [LendingClub] SET MULTI_USER -GO - -ALTER DATABASE [LendingClub] SET PAGE_VERIFY CHECKSUM -GO - -ALTER DATABASE [LendingClub] SET DB_CHAINING OFF -GO - -ALTER DATABASE [LendingClub] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF ) -GO - -ALTER DATABASE [LendingClub] SET TARGET_RECOVERY_TIME = 60 SECONDS -GO - -ALTER DATABASE [LendingClub] SET DELAYED_DURABILITY = DISABLED -GO - -ALTER DATABASE [LendingClub] SET QUERY_STORE = OFF -GO - -USE [LendingClub] -GO - -ALTER DATABASE SCOPED CONFIGURATION SET MAXDOP = 0; -GO - -ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET MAXDOP = PRIMARY; -GO - -ALTER DATABASE SCOPED CONFIGURATION SET LEGACY_CARDINALITY_ESTIMATION = OFF; -GO - -ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET LEGACY_CARDINALITY_ESTIMATION = PRIMARY; -GO - -ALTER DATABASE SCOPED CONFIGURATION SET PARAMETER_SNIFFING = ON; -GO - -ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET PARAMETER_SNIFFING = PRIMARY; -GO - -ALTER DATABASE SCOPED CONFIGURATION SET QUERY_OPTIMIZER_HOTFIXES = OFF; -GO - -ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET QUERY_OPTIMIZER_HOTFIXES = PRIMARY; -GO - -ALTER DATABASE [LendingClub] SET READ_WRITE -GO - -USE [LendingClub] -GO - - -SET ANSI_NULLS ON -GO - -SET QUOTED_IDENTIFIER ON -GO - -CREATE TABLE [dbo].[LoanStatsStaging] -( - [id] [int] NULL, - [member_id] [int] NULL, - [loan_amnt] [int] NULL, - [funded_amnt] [int] NULL, - [funded_amnt_inv] [int] NULL, - [term] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [int_rate] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [installment] [float] NULL, - [grade] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [sub_grade] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [emp_title] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [emp_length] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [home_ownership] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [annual_inc] [float] NULL, - [verification_status] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [issue_d] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [loan_status] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [pymnt_plan] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [url] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [desc] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [purpose] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [title] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [zip_code] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [addr_state] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [dti] [float] NULL, - [delinq_2yrs] [int] NULL, - [earliest_cr_line] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [inq_last_6mths] [int] NULL, - [mths_since_last_delinq] [int] NULL, - [mths_since_last_record] [int] NULL, - [open_acc] [int] NULL, - [pub_rec] [int] NULL, - [revol_bal] [int] NULL, - [revol_util] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [total_acc] [int] NULL, - [initial_list_status] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [out_prncp] [float] NULL, - [out_prncp_inv] [float] NULL, - [total_pymnt] [float] NULL, - [total_pymnt_inv] [float] NULL, - [total_rec_prncp] [float] NULL, - [total_rec_int] [float] NULL, - [total_rec_late_fee] [float] NULL, - [recoveries] [float] NULL, - [collection_recovery_fee] [float] NULL, - [last_pymnt_d] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [last_pymnt_amnt] [float] NULL, - [next_pymnt_d] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [last_credit_pull_d] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [collections_12_mths_ex_med] [int] NULL, - [mths_since_last_major_derog] [int] NULL, - [policy_code] [int] NULL, - [application_type] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [annual_inc_joint] [float] NULL, - [dti_joint] [float] NULL, - [verification_status_joint] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, - [acc_now_delinq] [int] NULL, - [tot_coll_amt] [int] NULL, - [tot_cur_bal] [int] NULL, - [open_acc_6m] [int] NULL, - [open_il_6m] [int] NULL, - [open_il_12m] [int] NULL, - [open_il_24m] [int] NULL, - [mths_since_rcnt_il] [int] NULL, - [total_bal_il] [int] NULL, - [il_util] [float] NULL, - [open_rv_12m] [int] NULL, - [open_rv_24m] [int] NULL, - [max_bal_bc] [int] NULL, - [all_util] [float] NULL, - [total_rev_hi_lim] [int] NULL, - [inq_fi] [int] NULL, - [total_cu_tl] [int] NULL, - [inq_last_12m] [int] NULL, - [acc_open_past_24mths] [int] NULL, - [avg_cur_bal] [int] NULL, - [bc_open_to_buy] [int] NULL, - [bc_util] [float] NULL, - [chargeoff_within_12_mths] [int] NULL, - [delinq_amnt] [int] NULL, - [mo_sin_old_il_acct] [int] NULL, - [mo_sin_old_rev_tl_op] [int] NULL, - [mo_sin_rcnt_rev_tl_op] [int] NULL, - [mo_sin_rcnt_tl] [int] NULL, - [mort_acc] [int] NULL, - [mths_since_recent_bc] [int] NULL, - [mths_since_recent_bc_dlq] [int] NULL, - [mths_since_recent_inq] [int] NULL, - [mths_since_recent_revol_delinq] [int] NULL, - [num_accts_ever_120_pd] [int] NULL, - [num_actv_bc_tl] [int] NULL, - [num_actv_rev_tl] [int] NULL, - [num_bc_sats] [int] NULL, - [num_bc_tl] [int] NULL, - [num_il_tl] [int] NULL, - [num_op_rev_tl] [int] NULL, - [num_rev_accts] [int] NULL, - [num_rev_tl_bal_gt_0] [int] NULL, - [num_sats] [int] NULL, - [num_tl_120dpd_2m] [int] NULL, - [num_tl_30dpd] [int] NULL, - [num_tl_90g_dpd_24m] [int] NULL, - [num_tl_op_past_12m] [int] NULL, - [pct_tl_nvr_dlq] [float] NULL, - [percent_bc_gt_75] [float] NULL, - [pub_rec_bankruptcies] [int] NULL, - [tax_liens] [int] NULL, - [tot_hi_cred_lim] [int] NULL, - [total_bal_ex_mort] [int] NULL, - [total_bc_limit] [int] NULL, - [total_il_high_credit_limit] [int] NULL, - -INDEX [LoanStats_index] NONCLUSTERED HASH -( - [id] -)WITH ( BUCKET_COUNT = 2000000) -)WITH ( MEMORY_OPTIMIZED = ON , DURABILITY = SCHEMA_ONLY ); - -GO - -SET ANSI_NULLS ON -GO - -SET QUOTED_IDENTIFIER ON -GO - -CREATE TABLE [dbo].[LoanStats]( - [id] [int] NOT NULL IDENTITY(1,1), - [member_id] [int] NULL, - [loan_amnt] [int] NULL, - [funded_amnt] [int] NULL, - [funded_amnt_inv] [int] NULL, - [term] [nvarchar](max) NULL, - [int_rate] [float] NULL, - [installment] [float] NULL, - [grade] [nvarchar](max) NULL, - [sub_grade] [nvarchar](max) NULL, - [emp_title] [nvarchar](max) NULL, - [emp_length] [nvarchar](max) NULL, - [home_ownership] [nvarchar](max) NULL, - [annual_inc] [float] NULL, - [verification_status] [nvarchar](max) NULL, - [issue_d] [nvarchar](max) NULL, - [loan_status] [nvarchar](max) NULL, - [pymnt_plan] [nvarchar](max) NULL, - [purpose] [nvarchar](max) NULL, - [title] [nvarchar](max) NULL, - [zip_code] [nvarchar](max) NULL, - [addr_state] [nvarchar](max) NULL, - [dti] [float] NULL, - [delinq_2yrs] [int] NULL, - [earliest_cr_line] [nvarchar](max) NULL, - [inq_last_6mths] [int] NULL, - [mths_since_last_delinq] [int] NULL, - [mths_since_last_record] [int] NULL, - [open_acc] [int] NULL, - [pub_rec] [int] NULL, - [revol_bal] [int] NULL, - [revol_util] [float] NULL, - [total_acc] [int] NULL, - [initial_list_status] [nvarchar](max) NULL, - [out_prncp] [float] NULL, - [out_prncp_inv] [float] NULL, - [total_pymnt] [float] NULL, - [total_pymnt_inv] [float] NULL, - [total_rec_prncp] [float] NULL, - [total_rec_int] [float] NULL, - [total_rec_late_fee] [float] NULL, - [recoveries] [float] NULL, - [collection_recovery_fee] [float] NULL, - [last_pymnt_d] [nvarchar](max) NULL, - [last_pymnt_amnt] [float] NULL, - [next_pymnt_d] [nvarchar](max) NULL, - [last_credit_pull_d] [nvarchar](max) NULL, - [collections_12_mths_ex_med] [int] NULL, - [mths_since_last_major_derog] [int] NULL, - [policy_code] [int] NULL, - [application_type] [nvarchar](max) NULL, - [annual_inc_joint] [float] NULL, - [dti_joint] [float] NULL, - [verification_status_joint] [nvarchar](max) NULL, - [acc_now_delinq] [int] NULL, - [tot_coll_amt] [int] NULL, - [tot_cur_bal] [int] NULL, - [open_acc_6m] [int] NULL, - [open_il_6m] [int] NULL, - [open_il_12m] [int] NULL, - [open_il_24m] [int] NULL, - [mths_since_rcnt_il] [int] NULL, - [total_bal_il] [int] NULL, - [il_util] [float] NULL, - [open_rv_12m] [int] NULL, - [open_rv_24m] [int] NULL, - [max_bal_bc] [int] NULL, - [all_util] [float] NULL, - [total_rev_hi_lim] [int] NULL, - [inq_fi] [int] NULL, - [total_cu_tl] [int] NULL, - [inq_last_12m] [int] NULL, - [acc_open_past_24mths] [int] NULL, - [avg_cur_bal] [int] NULL, - [bc_open_to_buy] [int] NULL, - [bc_util] [float] NULL, - [chargeoff_within_12_mths] [int] NULL, - [delinq_amnt] [int] NULL, - [mo_sin_old_il_acct] [int] NULL, - [mo_sin_old_rev_tl_op] [int] NULL, - [mo_sin_rcnt_rev_tl_op] [int] NULL, - [mo_sin_rcnt_tl] [int] NULL, - [mort_acc] [int] NULL, - [mths_since_recent_bc] [int] NULL, - [mths_since_recent_bc_dlq] [int] NULL, - [mths_since_recent_inq] [int] NULL, - [mths_since_recent_revol_delinq] [int] NULL, - [num_accts_ever_120_pd] [int] NULL, - [num_actv_bc_tl] [int] NULL, - [num_actv_rev_tl] [int] NULL, - [num_bc_sats] [int] NULL, - [num_bc_tl] [int] NULL, - [num_il_tl] [int] NULL, - [num_op_rev_tl] [int] NULL, - [num_rev_accts] [int] NULL, - [num_rev_tl_bal_gt_0] [int] NULL, - [num_sats] [int] NULL, - [num_tl_120dpd_2m] [int] NULL, - [num_tl_30dpd] [int] NULL, - [num_tl_90g_dpd_24m] [int] NULL, - [num_tl_op_past_12m] [int] NULL, - [pct_tl_nvr_dlq] [float] NULL, - [percent_bc_gt_75] [float] NULL, - [pub_rec_bankruptcies] [int] NULL, - [tax_liens] [int] NULL, - [tot_hi_cred_lim] [int] NULL, - [total_bal_ex_mort] [int] NULL, - [total_bc_limit] [int] NULL, - [total_il_high_credit_limit] [int] NULL, - [is_bad] int NULL, - CONSTRAINT [PK__LoanStat] PRIMARY KEY CLUSTERED -( - [id] ASC -)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] -) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] - -GO - - - -SET ANSI_NULLS ON -GO - -SET QUOTED_IDENTIFIER ON -GO - - -USE [LendingClub] -GO -/****** Object: StoredProcedure [dbo].[PerformETL] Script Date: 12/31/2016 3:00:22 AM ******/ -SET ANSI_NULLS ON -GO -SET QUOTED_IDENTIFIER ON -GO - -CREATE PROCEDURE [dbo].[PerformETL] -AS -BEGIN - INSERT INTO [dbo].[LoanStats] - ( - [member_id] - ,[loan_amnt] - ,[funded_amnt] - ,[funded_amnt_inv] - ,[term] - ,[int_rate] - ,[installment] - ,[grade] - ,[sub_grade] - ,[emp_title] - ,[emp_length] - ,[home_ownership] - ,[annual_inc] - ,[verification_status] - ,[issue_d] - ,[loan_status] - ,[pymnt_plan] - ,[purpose] - ,[title] - ,[zip_code] - ,[addr_state] - ,[dti] - ,[delinq_2yrs] - ,[earliest_cr_line] - ,[inq_last_6mths] - ,[mths_since_last_delinq] - ,[mths_since_last_record] - ,[open_acc] - ,[pub_rec] - ,[revol_bal] - ,[revol_util] - ,[total_acc] - ,[initial_list_status] - ,[out_prncp] - ,[out_prncp_inv] - ,[total_pymnt] - ,[total_pymnt_inv] - ,[total_rec_prncp] - ,[total_rec_int] - ,[total_rec_late_fee] - ,[recoveries] - ,[collection_recovery_fee] - ,[last_pymnt_d] - ,[last_pymnt_amnt] - ,[next_pymnt_d] - ,[last_credit_pull_d] - ,[collections_12_mths_ex_med] - ,[mths_since_last_major_derog] - ,[policy_code] - ,[application_type] - ,[annual_inc_joint] - ,[dti_joint] - ,[verification_status_joint] - ,[acc_now_delinq] - ,[tot_coll_amt] - ,[tot_cur_bal] - ,[open_acc_6m] - ,[open_il_6m] - ,[open_il_12m] - ,[open_il_24m] - ,[mths_since_rcnt_il] - ,[total_bal_il] - ,[il_util] - ,[open_rv_12m] - ,[open_rv_24m] - ,[max_bal_bc] - ,[all_util] - ,[total_rev_hi_lim] - ,[inq_fi] - ,[total_cu_tl] - ,[inq_last_12m] - ,[acc_open_past_24mths] - ,[avg_cur_bal] - ,[bc_open_to_buy] - ,[bc_util] - ,[chargeoff_within_12_mths] - ,[delinq_amnt] - ,[mo_sin_old_il_acct] - ,[mo_sin_old_rev_tl_op] - ,[mo_sin_rcnt_rev_tl_op] - ,[mo_sin_rcnt_tl] - ,[mort_acc] - ,[mths_since_recent_bc] - ,[mths_since_recent_bc_dlq] - ,[mths_since_recent_inq] - ,[mths_since_recent_revol_delinq] - ,[num_accts_ever_120_pd] - ,[num_actv_bc_tl] - ,[num_actv_rev_tl] - ,[num_bc_sats] - ,[num_bc_tl] - ,[num_il_tl] - ,[num_op_rev_tl] - ,[num_rev_accts] - ,[num_rev_tl_bal_gt_0] - ,[num_sats] - ,[num_tl_120dpd_2m] - ,[num_tl_30dpd] - ,[num_tl_90g_dpd_24m] - ,[num_tl_op_past_12m] - ,[pct_tl_nvr_dlq] - ,[percent_bc_gt_75] - ,[pub_rec_bankruptcies] - ,[tax_liens] - ,[tot_hi_cred_lim] - ,[total_bal_ex_mort] - ,[total_bc_limit] - ,[total_il_high_credit_limit]) - SELECT DISTINCT - [member_id] - ,[loan_amnt] - ,[funded_amnt] - ,[funded_amnt_inv] - ,[term] - ,REPLACE([int_rate], '%', '') - ,[installment] - ,[grade] - ,[sub_grade] - ,[emp_title] - ,[emp_length] - ,[home_ownership] - ,[annual_inc] - ,[verification_status] - ,[issue_d] - ,[loan_status] - ,[pymnt_plan] - ,[purpose] - ,[title] - ,[zip_code] - ,[addr_state] - ,[dti] - ,[delinq_2yrs] - ,[earliest_cr_line] - ,[inq_last_6mths] - ,[mths_since_last_delinq] - ,[mths_since_last_record] - ,[open_acc] - ,[pub_rec] - ,[revol_bal] - ,REPLACE([revol_util], '%', '') - ,[total_acc] - ,[initial_list_status] - ,[out_prncp] - ,[out_prncp_inv] - ,[total_pymnt] - ,[total_pymnt_inv] - ,[total_rec_prncp] - ,[total_rec_int] - ,[total_rec_late_fee] - ,[recoveries] - ,[collection_recovery_fee] - ,[last_pymnt_d] - ,[last_pymnt_amnt] - ,[next_pymnt_d] - ,[last_credit_pull_d] - ,[collections_12_mths_ex_med] - ,[mths_since_last_major_derog] - ,[policy_code] - ,[application_type] - ,[annual_inc_joint] - ,[dti_joint] - ,[verification_status_joint] - ,[acc_now_delinq] - ,[tot_coll_amt] - ,[tot_cur_bal] - ,[open_acc_6m] - ,[open_il_6m] - ,[open_il_12m] - ,[open_il_24m] - ,[mths_since_rcnt_il] - ,[total_bal_il] - ,[il_util] - ,[open_rv_12m] - ,[open_rv_24m] - ,[max_bal_bc] - ,[all_util] - ,[total_rev_hi_lim] - ,[inq_fi] - ,[total_cu_tl] - ,[inq_last_12m] - ,[acc_open_past_24mths] - ,[avg_cur_bal] - ,[bc_open_to_buy] - ,[bc_util] - ,[chargeoff_within_12_mths] - ,[delinq_amnt] - ,[mo_sin_old_il_acct] - ,[mo_sin_old_rev_tl_op] - ,[mo_sin_rcnt_rev_tl_op] - ,[mo_sin_rcnt_tl] - ,[mort_acc] - ,[mths_since_recent_bc] - ,[mths_since_recent_bc_dlq] - ,[mths_since_recent_inq] - ,[mths_since_recent_revol_delinq] - ,[num_accts_ever_120_pd] - ,[num_actv_bc_tl] - ,[num_actv_rev_tl] - ,[num_bc_sats] - ,[num_bc_tl] - ,[num_il_tl] - ,[num_op_rev_tl] - ,[num_rev_accts] - ,[num_rev_tl_bal_gt_0] - ,[num_sats] - ,[num_tl_120dpd_2m] - ,[num_tl_30dpd] - ,[num_tl_90g_dpd_24m] - ,[num_tl_op_past_12m] - ,[pct_tl_nvr_dlq] - ,[percent_bc_gt_75] - ,[pub_rec_bankruptcies] - ,[tax_liens] - ,[tot_hi_cred_lim] - ,[total_bal_ex_mort] - ,[total_bc_limit] - ,[total_il_high_credit_limit] - FROM [dbo].[LoanStatsStaging] - WHERE [loan_status] IS NOT NULL - - DELETE FROM [dbo].[LoanStatsStaging] -END ; -GO - -USE [LendingClub] -GO - -SET ANSI_NULLS ON -GO - -SET QUOTED_IDENTIFIER ON -GO - -CREATE TABLE [dbo].[LoanStatsPredictions] -( - [is_bad_Pred] [float] NULL, - [id] [int] NULL - -INDEX [LoanStats_index] NONCLUSTERED HASH -( - [id] -)WITH ( BUCKET_COUNT = 2000000) -)WITH ( MEMORY_OPTIMIZED = ON , DURABILITY = SCHEMA_ONLY ); - -GO - -SET ANSI_NULLS ON -GO -SET QUOTED_IDENTIFIER ON -GO -CREATE TABLE [dbo].[LoanPredictionsWhatIf] -( - [is_bad_Pred] [float] NULL, - [id] [int] NULL - -INDEX [LoanStats_index] NONCLUSTERED HASH -( - [id] -)WITH ( BUCKET_COUNT = 2000000) -)WITH ( MEMORY_OPTIMIZED = ON , DURABILITY = SCHEMA_ONLY ); -GO - -SET ANSI_NULLS ON -GO - -SET QUOTED_IDENTIFIER ON -GO - -CREATE TABLE [dbo].[RunTimeStats] -( - [SessionID] [int] NOT NULL, - [RunTime] [datetime] NOT NULL, - [Operation] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, - -INDEX [RunTimeStats_index] NONCLUSTERED HASH -( - [SessionID] -)WITH ( BUCKET_COUNT = 32) -)WITH ( MEMORY_OPTIMIZED = ON , DURABILITY = SCHEMA_ONLY ) - -GO - - -SET ANSI_NULLS ON -GO - -SET QUOTED_IDENTIFIER ON -GO --- Create a table to store the WhatIf value used for the WhatIf scenario -CREATE TABLE [dbo].[WhatIf]( - [Rate] [float] NULL -) ON [PRIMARY] - -GO - -INSERT INTO [dbo].[WhatIf] VALUES (0.0) - - -SET ANSI_NULLS ON -GO - -SET QUOTED_IDENTIFIER ON -GO - --- Stored procedure for scoring loans for the base predictions -CREATE PROCEDURE [dbo].[ScoreLoans] -@start bigint, -@end bigint -AS -BEGIN - - -- Declare the variables to get the input data and the scoring model - DECLARE @inquery nvarchar(max) = N'SELECT id,revol_util, int_rate, mths_since_last_record, annual_inc_joint, dti_joint, total_rec_prncp, all_util, is_bad FROM [dbo].[LoanStats] where [id] >= ' + CAST(@start as varchar(255)) + 'and [id] <= ' + CAST(@end as varchar(255)); - DECLARE @model varbinary(max) = (SELECT TOP 1 [model] FROM [dbo].[models]) - - -- Log beginning of processing time - INSERT INTO [dbo].[RunTimeStats] VALUES (@@SPID, GETDATE(),'Start') - - -- Score the loans and store them in a table - INSERT INTO [dbo].[LoanStatsPredictions] - EXEC sp_execute_external_script - @language = N'R', - @script = N' - rfModel <- unserialize(as.raw(model)); - OutputDataSet<-rxPredict(rfModel, data = InputDataSet, extraVarsToWrite = c("id")) - ', - @input_data_1 = @inquery, - @params = N'@model varbinary(max)', - @model = @model - - -- Log end of processing time - INSERT INTO [dbo].[RunTimeStats] VALUES (@@SPID, GETDATE(),'End') - -END -GO - - -SET ANSI_NULLS ON -GO -SET QUOTED_IDENTIFIER ON -GO - --- Stored procedure to in -CREATE PROCEDURE [dbo].[ScoreLoansWhatIf] -@start bigint, -@end bigint, -@incr float -AS -BEGIN - - -- Declare the variables to get the input data and the scoring model - DECLARE @inquery nvarchar(max) = N'SELECT id,revol_util, (int_rate+ ' + CAST (@Incr as varchar(5)) + ') as int_rate, mths_since_last_record, annual_inc_joint, dti_joint, total_rec_prncp, all_util,is_bad FROM [dbo].[LoanStats] where [id] >= ' + CAST(@start as varchar(255)) + 'and [id] <= ' + CAST(@end as varchar(255)); - DECLARE @model varbinary(max) = (SELECT TOP 1 [model] FROM [dbo].[models]) - - -- Log beginning of processing time - INSERT INTO [dbo].[RunTimeStats] VALUES (@@SPID, GETDATE(),'Start') - - INSERT INTO [dbo].[LoanPredictionsWhatIf] - EXEC sp_execute_external_script - @language = N'R', - @script = N' - rfModel <- unserialize(as.raw(model)); - OutputDataSet<-rxPredict(rfModel, data = InputDataSet, extraVarsToWrite = c("id")) - ', - @input_data_1 = @inquery, - @params = N'@model varbinary(max)', - @model = @model - - -- Log end of processing time - INSERT INTO [dbo].[RunTimeStats] VALUES (@@SPID, GETDATE(),'End') - - -END - -GO - +USE [master] +GO + +/****** Object: Database [LendingClub] Script Date: 12/29/2016 9:29:37 PM ******/ +CREATE DATABASE [LendingClub] + CONTAINMENT = NONE + ON PRIMARY +( NAME = N'LendingClubData', FILENAME = N'C:\Tiger\DATA\LendingClub.mdf' , SIZE = 19210240KB , MAXSIZE = UNLIMITED, FILEGROWTH = 65536MB ), + FILEGROUP [InMemOLTP] CONTAINS MEMORY_OPTIMIZED_DATA DEFAULT +( NAME = N'InMem', FILENAME = N'C:\Tiger\DATA\InMem' , MAXSIZE = UNLIMITED) + LOG ON +( NAME = N'LendingClubLog', FILENAME = N'C:\Tiger\DATA\LendingClub_log.ldf' , SIZE = 512MB , MAXSIZE = 2048GB , FILEGROWTH = 64MB ) +GO + +ALTER DATABASE [LendingClub] SET COMPATIBILITY_LEVEL = 130 +GO + +ALTER DATABASE [LendingClub] SET ANSI_NULL_DEFAULT OFF +GO + +ALTER DATABASE [LendingClub] SET ANSI_NULLS OFF +GO + +ALTER DATABASE [LendingClub] SET ANSI_PADDING OFF +GO + +ALTER DATABASE [LendingClub] SET ANSI_WARNINGS OFF +GO + +ALTER DATABASE [LendingClub] SET ARITHABORT OFF +GO + +ALTER DATABASE [LendingClub] SET AUTO_CLOSE OFF +GO + +ALTER DATABASE [LendingClub] SET AUTO_SHRINK OFF +GO + +ALTER DATABASE [LendingClub] SET AUTO_UPDATE_STATISTICS ON +GO + +ALTER DATABASE [LendingClub] SET CURSOR_CLOSE_ON_COMMIT OFF +GO + +ALTER DATABASE [LendingClub] SET CURSOR_DEFAULT GLOBAL +GO + +ALTER DATABASE [LendingClub] SET CONCAT_NULL_YIELDS_NULL OFF +GO + +ALTER DATABASE [LendingClub] SET NUMERIC_ROUNDABORT OFF +GO + +ALTER DATABASE [LendingClub] SET QUOTED_IDENTIFIER OFF +GO + +ALTER DATABASE [LendingClub] SET RECURSIVE_TRIGGERS OFF +GO + +ALTER DATABASE [LendingClub] SET ENABLE_BROKER +GO + +ALTER DATABASE [LendingClub] SET AUTO_UPDATE_STATISTICS_ASYNC OFF +GO + +ALTER DATABASE [LendingClub] SET DATE_CORRELATION_OPTIMIZATION OFF +GO + +ALTER DATABASE [LendingClub] SET TRUSTWORTHY OFF +GO + +ALTER DATABASE [LendingClub] SET ALLOW_SNAPSHOT_ISOLATION OFF +GO + +ALTER DATABASE [LendingClub] SET PARAMETERIZATION SIMPLE +GO + +ALTER DATABASE [LendingClub] SET READ_COMMITTED_SNAPSHOT OFF +GO + +ALTER DATABASE [LendingClub] SET HONOR_BROKER_PRIORITY OFF +GO + +ALTER DATABASE [LendingClub] SET RECOVERY SIMPLE +GO + +ALTER DATABASE [LendingClub] SET MULTI_USER +GO + +ALTER DATABASE [LendingClub] SET PAGE_VERIFY CHECKSUM +GO + +ALTER DATABASE [LendingClub] SET DB_CHAINING OFF +GO + +ALTER DATABASE [LendingClub] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF ) +GO + +ALTER DATABASE [LendingClub] SET TARGET_RECOVERY_TIME = 60 SECONDS +GO + +ALTER DATABASE [LendingClub] SET DELAYED_DURABILITY = DISABLED +GO + +ALTER DATABASE [LendingClub] SET QUERY_STORE = OFF +GO + +USE [LendingClub] +GO + +ALTER DATABASE SCOPED CONFIGURATION SET MAXDOP = 0; +GO + +ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET MAXDOP = PRIMARY; +GO + +ALTER DATABASE SCOPED CONFIGURATION SET LEGACY_CARDINALITY_ESTIMATION = OFF; +GO + +ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET LEGACY_CARDINALITY_ESTIMATION = PRIMARY; +GO + +ALTER DATABASE SCOPED CONFIGURATION SET PARAMETER_SNIFFING = ON; +GO + +ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET PARAMETER_SNIFFING = PRIMARY; +GO + +ALTER DATABASE SCOPED CONFIGURATION SET QUERY_OPTIMIZER_HOTFIXES = OFF; +GO + +ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET QUERY_OPTIMIZER_HOTFIXES = PRIMARY; +GO + +ALTER DATABASE [LendingClub] SET READ_WRITE +GO + +USE [LendingClub] +GO + + +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE TABLE [dbo].[LoanStatsStaging] +( + [id] [int] NULL, + [member_id] [int] NULL, + [loan_amnt] [int] NULL, + [funded_amnt] [int] NULL, + [funded_amnt_inv] [int] NULL, + [term] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, + [int_rate] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, + [installment] [float] NULL, + [grade] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, + [sub_grade] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, + [emp_title] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, + [emp_length] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, + [home_ownership] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, + [annual_inc] [float] NULL, + [verification_status] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, + [issue_d] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, + [loan_status] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, + [pymnt_plan] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, + [url] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, + [desc] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, + [purpose] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, + [title] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, + [zip_code] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, + [addr_state] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, + [dti] [float] NULL, + [delinq_2yrs] [int] NULL, + [earliest_cr_line] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, + [inq_last_6mths] [int] NULL, + [mths_since_last_delinq] [int] NULL, + [mths_since_last_record] [int] NULL, + [open_acc] [int] NULL, + [pub_rec] [int] NULL, + [revol_bal] [int] NULL, + [revol_util] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, + [total_acc] [int] NULL, + [initial_list_status] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, + [out_prncp] [float] NULL, + [out_prncp_inv] [float] NULL, + [total_pymnt] [float] NULL, + [total_pymnt_inv] [float] NULL, + [total_rec_prncp] [float] NULL, + [total_rec_int] [float] NULL, + [total_rec_late_fee] [float] NULL, + [recoveries] [float] NULL, + [collection_recovery_fee] [float] NULL, + [last_pymnt_d] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, + [last_pymnt_amnt] [float] NULL, + [next_pymnt_d] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, + [last_credit_pull_d] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, + [collections_12_mths_ex_med] [int] NULL, + [mths_since_last_major_derog] [int] NULL, + [policy_code] [int] NULL, + [application_type] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, + [annual_inc_joint] [float] NULL, + [dti_joint] [float] NULL, + [verification_status_joint] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, + [acc_now_delinq] [int] NULL, + [tot_coll_amt] [int] NULL, + [tot_cur_bal] [int] NULL, + [open_acc_6m] [int] NULL, + [open_il_6m] [int] NULL, + [open_il_12m] [int] NULL, + [open_il_24m] [int] NULL, + [mths_since_rcnt_il] [int] NULL, + [total_bal_il] [int] NULL, + [il_util] [float] NULL, + [open_rv_12m] [int] NULL, + [open_rv_24m] [int] NULL, + [max_bal_bc] [int] NULL, + [all_util] [float] NULL, + [total_rev_hi_lim] [int] NULL, + [inq_fi] [int] NULL, + [total_cu_tl] [int] NULL, + [inq_last_12m] [int] NULL, + [acc_open_past_24mths] [int] NULL, + [avg_cur_bal] [int] NULL, + [bc_open_to_buy] [int] NULL, + [bc_util] [float] NULL, + [chargeoff_within_12_mths] [int] NULL, + [delinq_amnt] [int] NULL, + [mo_sin_old_il_acct] [int] NULL, + [mo_sin_old_rev_tl_op] [int] NULL, + [mo_sin_rcnt_rev_tl_op] [int] NULL, + [mo_sin_rcnt_tl] [int] NULL, + [mort_acc] [int] NULL, + [mths_since_recent_bc] [int] NULL, + [mths_since_recent_bc_dlq] [int] NULL, + [mths_since_recent_inq] [int] NULL, + [mths_since_recent_revol_delinq] [int] NULL, + [num_accts_ever_120_pd] [int] NULL, + [num_actv_bc_tl] [int] NULL, + [num_actv_rev_tl] [int] NULL, + [num_bc_sats] [int] NULL, + [num_bc_tl] [int] NULL, + [num_il_tl] [int] NULL, + [num_op_rev_tl] [int] NULL, + [num_rev_accts] [int] NULL, + [num_rev_tl_bal_gt_0] [int] NULL, + [num_sats] [int] NULL, + [num_tl_120dpd_2m] [int] NULL, + [num_tl_30dpd] [int] NULL, + [num_tl_90g_dpd_24m] [int] NULL, + [num_tl_op_past_12m] [int] NULL, + [pct_tl_nvr_dlq] [float] NULL, + [percent_bc_gt_75] [float] NULL, + [pub_rec_bankruptcies] [int] NULL, + [tax_liens] [int] NULL, + [tot_hi_cred_lim] [int] NULL, + [total_bal_ex_mort] [int] NULL, + [total_bc_limit] [int] NULL, + [total_il_high_credit_limit] [int] NULL, + +INDEX [LoanStats_index] NONCLUSTERED HASH +( + [id] +)WITH ( BUCKET_COUNT = 2000000) +)WITH ( MEMORY_OPTIMIZED = ON , DURABILITY = SCHEMA_ONLY ); + +GO + +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE TABLE [dbo].[LoanStats]( + [id] [int] NOT NULL IDENTITY(1,1), + [member_id] [int] NULL, + [loan_amnt] [int] NULL, + [funded_amnt] [int] NULL, + [funded_amnt_inv] [int] NULL, + [term] [nvarchar](max) NULL, + [int_rate] [float] NULL, + [installment] [float] NULL, + [grade] [nvarchar](max) NULL, + [sub_grade] [nvarchar](max) NULL, + [emp_title] [nvarchar](max) NULL, + [emp_length] [nvarchar](max) NULL, + [home_ownership] [nvarchar](max) NULL, + [annual_inc] [float] NULL, + [verification_status] [nvarchar](max) NULL, + [issue_d] [nvarchar](max) NULL, + [loan_status] [nvarchar](max) NULL, + [pymnt_plan] [nvarchar](max) NULL, + [purpose] [nvarchar](max) NULL, + [title] [nvarchar](max) NULL, + [zip_code] [nvarchar](max) NULL, + [addr_state] [nvarchar](max) NULL, + [dti] [float] NULL, + [delinq_2yrs] [int] NULL, + [earliest_cr_line] [nvarchar](max) NULL, + [inq_last_6mths] [int] NULL, + [mths_since_last_delinq] [int] NULL, + [mths_since_last_record] [int] NULL, + [open_acc] [int] NULL, + [pub_rec] [int] NULL, + [revol_bal] [int] NULL, + [revol_util] [float] NULL, + [total_acc] [int] NULL, + [initial_list_status] [nvarchar](max) NULL, + [out_prncp] [float] NULL, + [out_prncp_inv] [float] NULL, + [total_pymnt] [float] NULL, + [total_pymnt_inv] [float] NULL, + [total_rec_prncp] [float] NULL, + [total_rec_int] [float] NULL, + [total_rec_late_fee] [float] NULL, + [recoveries] [float] NULL, + [collection_recovery_fee] [float] NULL, + [last_pymnt_d] [nvarchar](max) NULL, + [last_pymnt_amnt] [float] NULL, + [next_pymnt_d] [nvarchar](max) NULL, + [last_credit_pull_d] [nvarchar](max) NULL, + [collections_12_mths_ex_med] [int] NULL, + [mths_since_last_major_derog] [int] NULL, + [policy_code] [int] NULL, + [application_type] [nvarchar](max) NULL, + [annual_inc_joint] [float] NULL, + [dti_joint] [float] NULL, + [verification_status_joint] [nvarchar](max) NULL, + [acc_now_delinq] [int] NULL, + [tot_coll_amt] [int] NULL, + [tot_cur_bal] [int] NULL, + [open_acc_6m] [int] NULL, + [open_il_6m] [int] NULL, + [open_il_12m] [int] NULL, + [open_il_24m] [int] NULL, + [mths_since_rcnt_il] [int] NULL, + [total_bal_il] [int] NULL, + [il_util] [float] NULL, + [open_rv_12m] [int] NULL, + [open_rv_24m] [int] NULL, + [max_bal_bc] [int] NULL, + [all_util] [float] NULL, + [total_rev_hi_lim] [int] NULL, + [inq_fi] [int] NULL, + [total_cu_tl] [int] NULL, + [inq_last_12m] [int] NULL, + [acc_open_past_24mths] [int] NULL, + [avg_cur_bal] [int] NULL, + [bc_open_to_buy] [int] NULL, + [bc_util] [float] NULL, + [chargeoff_within_12_mths] [int] NULL, + [delinq_amnt] [int] NULL, + [mo_sin_old_il_acct] [int] NULL, + [mo_sin_old_rev_tl_op] [int] NULL, + [mo_sin_rcnt_rev_tl_op] [int] NULL, + [mo_sin_rcnt_tl] [int] NULL, + [mort_acc] [int] NULL, + [mths_since_recent_bc] [int] NULL, + [mths_since_recent_bc_dlq] [int] NULL, + [mths_since_recent_inq] [int] NULL, + [mths_since_recent_revol_delinq] [int] NULL, + [num_accts_ever_120_pd] [int] NULL, + [num_actv_bc_tl] [int] NULL, + [num_actv_rev_tl] [int] NULL, + [num_bc_sats] [int] NULL, + [num_bc_tl] [int] NULL, + [num_il_tl] [int] NULL, + [num_op_rev_tl] [int] NULL, + [num_rev_accts] [int] NULL, + [num_rev_tl_bal_gt_0] [int] NULL, + [num_sats] [int] NULL, + [num_tl_120dpd_2m] [int] NULL, + [num_tl_30dpd] [int] NULL, + [num_tl_90g_dpd_24m] [int] NULL, + [num_tl_op_past_12m] [int] NULL, + [pct_tl_nvr_dlq] [float] NULL, + [percent_bc_gt_75] [float] NULL, + [pub_rec_bankruptcies] [int] NULL, + [tax_liens] [int] NULL, + [tot_hi_cred_lim] [int] NULL, + [total_bal_ex_mort] [int] NULL, + [total_bc_limit] [int] NULL, + [total_il_high_credit_limit] [int] NULL, + [is_bad] int NULL, + CONSTRAINT [PK__LoanStat] PRIMARY KEY CLUSTERED +( + [id] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] +) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] + +GO + + + +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + + +USE [LendingClub] +GO +/****** Object: StoredProcedure [dbo].[PerformETL] Script Date: 12/31/2016 3:00:22 AM ******/ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + +CREATE PROCEDURE [dbo].[PerformETL] +AS +BEGIN + INSERT INTO [dbo].[LoanStats] + ( + [member_id] + ,[loan_amnt] + ,[funded_amnt] + ,[funded_amnt_inv] + ,[term] + ,[int_rate] + ,[installment] + ,[grade] + ,[sub_grade] + ,[emp_title] + ,[emp_length] + ,[home_ownership] + ,[annual_inc] + ,[verification_status] + ,[issue_d] + ,[loan_status] + ,[pymnt_plan] + ,[purpose] + ,[title] + ,[zip_code] + ,[addr_state] + ,[dti] + ,[delinq_2yrs] + ,[earliest_cr_line] + ,[inq_last_6mths] + ,[mths_since_last_delinq] + ,[mths_since_last_record] + ,[open_acc] + ,[pub_rec] + ,[revol_bal] + ,[revol_util] + ,[total_acc] + ,[initial_list_status] + ,[out_prncp] + ,[out_prncp_inv] + ,[total_pymnt] + ,[total_pymnt_inv] + ,[total_rec_prncp] + ,[total_rec_int] + ,[total_rec_late_fee] + ,[recoveries] + ,[collection_recovery_fee] + ,[last_pymnt_d] + ,[last_pymnt_amnt] + ,[next_pymnt_d] + ,[last_credit_pull_d] + ,[collections_12_mths_ex_med] + ,[mths_since_last_major_derog] + ,[policy_code] + ,[application_type] + ,[annual_inc_joint] + ,[dti_joint] + ,[verification_status_joint] + ,[acc_now_delinq] + ,[tot_coll_amt] + ,[tot_cur_bal] + ,[open_acc_6m] + ,[open_il_6m] + ,[open_il_12m] + ,[open_il_24m] + ,[mths_since_rcnt_il] + ,[total_bal_il] + ,[il_util] + ,[open_rv_12m] + ,[open_rv_24m] + ,[max_bal_bc] + ,[all_util] + ,[total_rev_hi_lim] + ,[inq_fi] + ,[total_cu_tl] + ,[inq_last_12m] + ,[acc_open_past_24mths] + ,[avg_cur_bal] + ,[bc_open_to_buy] + ,[bc_util] + ,[chargeoff_within_12_mths] + ,[delinq_amnt] + ,[mo_sin_old_il_acct] + ,[mo_sin_old_rev_tl_op] + ,[mo_sin_rcnt_rev_tl_op] + ,[mo_sin_rcnt_tl] + ,[mort_acc] + ,[mths_since_recent_bc] + ,[mths_since_recent_bc_dlq] + ,[mths_since_recent_inq] + ,[mths_since_recent_revol_delinq] + ,[num_accts_ever_120_pd] + ,[num_actv_bc_tl] + ,[num_actv_rev_tl] + ,[num_bc_sats] + ,[num_bc_tl] + ,[num_il_tl] + ,[num_op_rev_tl] + ,[num_rev_accts] + ,[num_rev_tl_bal_gt_0] + ,[num_sats] + ,[num_tl_120dpd_2m] + ,[num_tl_30dpd] + ,[num_tl_90g_dpd_24m] + ,[num_tl_op_past_12m] + ,[pct_tl_nvr_dlq] + ,[percent_bc_gt_75] + ,[pub_rec_bankruptcies] + ,[tax_liens] + ,[tot_hi_cred_lim] + ,[total_bal_ex_mort] + ,[total_bc_limit] + ,[total_il_high_credit_limit]) + SELECT DISTINCT + [member_id] + ,[loan_amnt] + ,[funded_amnt] + ,[funded_amnt_inv] + ,[term] + ,REPLACE([int_rate], '%', '') + ,[installment] + ,[grade] + ,[sub_grade] + ,[emp_title] + ,[emp_length] + ,[home_ownership] + ,[annual_inc] + ,[verification_status] + ,[issue_d] + ,[loan_status] + ,[pymnt_plan] + ,[purpose] + ,[title] + ,[zip_code] + ,[addr_state] + ,[dti] + ,[delinq_2yrs] + ,[earliest_cr_line] + ,[inq_last_6mths] + ,[mths_since_last_delinq] + ,[mths_since_last_record] + ,[open_acc] + ,[pub_rec] + ,[revol_bal] + ,REPLACE([revol_util], '%', '') + ,[total_acc] + ,[initial_list_status] + ,[out_prncp] + ,[out_prncp_inv] + ,[total_pymnt] + ,[total_pymnt_inv] + ,[total_rec_prncp] + ,[total_rec_int] + ,[total_rec_late_fee] + ,[recoveries] + ,[collection_recovery_fee] + ,[last_pymnt_d] + ,[last_pymnt_amnt] + ,[next_pymnt_d] + ,[last_credit_pull_d] + ,[collections_12_mths_ex_med] + ,[mths_since_last_major_derog] + ,[policy_code] + ,[application_type] + ,[annual_inc_joint] + ,[dti_joint] + ,[verification_status_joint] + ,[acc_now_delinq] + ,[tot_coll_amt] + ,[tot_cur_bal] + ,[open_acc_6m] + ,[open_il_6m] + ,[open_il_12m] + ,[open_il_24m] + ,[mths_since_rcnt_il] + ,[total_bal_il] + ,[il_util] + ,[open_rv_12m] + ,[open_rv_24m] + ,[max_bal_bc] + ,[all_util] + ,[total_rev_hi_lim] + ,[inq_fi] + ,[total_cu_tl] + ,[inq_last_12m] + ,[acc_open_past_24mths] + ,[avg_cur_bal] + ,[bc_open_to_buy] + ,[bc_util] + ,[chargeoff_within_12_mths] + ,[delinq_amnt] + ,[mo_sin_old_il_acct] + ,[mo_sin_old_rev_tl_op] + ,[mo_sin_rcnt_rev_tl_op] + ,[mo_sin_rcnt_tl] + ,[mort_acc] + ,[mths_since_recent_bc] + ,[mths_since_recent_bc_dlq] + ,[mths_since_recent_inq] + ,[mths_since_recent_revol_delinq] + ,[num_accts_ever_120_pd] + ,[num_actv_bc_tl] + ,[num_actv_rev_tl] + ,[num_bc_sats] + ,[num_bc_tl] + ,[num_il_tl] + ,[num_op_rev_tl] + ,[num_rev_accts] + ,[num_rev_tl_bal_gt_0] + ,[num_sats] + ,[num_tl_120dpd_2m] + ,[num_tl_30dpd] + ,[num_tl_90g_dpd_24m] + ,[num_tl_op_past_12m] + ,[pct_tl_nvr_dlq] + ,[percent_bc_gt_75] + ,[pub_rec_bankruptcies] + ,[tax_liens] + ,[tot_hi_cred_lim] + ,[total_bal_ex_mort] + ,[total_bc_limit] + ,[total_il_high_credit_limit] + FROM [dbo].[LoanStatsStaging] + WHERE [loan_status] IS NOT NULL + + DELETE FROM [dbo].[LoanStatsStaging] +END ; +GO + +USE [LendingClub] +GO + +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE TABLE [dbo].[LoanStatsPredictions] +( + [is_bad_Pred] [float] NULL, + [id] [int] NULL + +INDEX [LoanStats_index] NONCLUSTERED HASH +( + [id] +)WITH ( BUCKET_COUNT = 2000000) +)WITH ( MEMORY_OPTIMIZED = ON , DURABILITY = SCHEMA_ONLY ); + +GO + +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +CREATE TABLE [dbo].[LoanPredictionsWhatIf] +( + [is_bad_Pred] [float] NULL, + [id] [int] NULL + +INDEX [LoanStats_index] NONCLUSTERED HASH +( + [id] +)WITH ( BUCKET_COUNT = 2000000) +)WITH ( MEMORY_OPTIMIZED = ON , DURABILITY = SCHEMA_ONLY ); +GO + +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE TABLE [dbo].[RunTimeStats] +( + [SessionID] [int] NOT NULL, + [RunTime] [datetime] NOT NULL, + [Operation] [varchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, + +INDEX [RunTimeStats_index] NONCLUSTERED HASH +( + [SessionID] +)WITH ( BUCKET_COUNT = 32) +)WITH ( MEMORY_OPTIMIZED = ON , DURABILITY = SCHEMA_ONLY ) + +GO + + +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO +-- Create a table to store the WhatIf value used for the WhatIf scenario +CREATE TABLE [dbo].[WhatIf]( + [Rate] [float] NULL +) ON [PRIMARY] + +GO + +INSERT INTO [dbo].[WhatIf] VALUES (0.0) + + +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +-- Stored procedure for scoring loans for the base predictions +CREATE PROCEDURE [dbo].[ScoreLoans] +@start bigint, +@end bigint +AS +BEGIN + + -- Declare the variables to get the input data and the scoring model + DECLARE @inquery nvarchar(max) = N'SELECT id,revol_util, int_rate, mths_since_last_record, annual_inc_joint, dti_joint, total_rec_prncp, all_util, is_bad FROM [dbo].[LoanStats] where [id] >= ' + CAST(@start as varchar(255)) + 'and [id] <= ' + CAST(@end as varchar(255)); + DECLARE @model varbinary(max) = (SELECT TOP 1 [model] FROM [dbo].[models]) + + -- Log beginning of processing time + INSERT INTO [dbo].[RunTimeStats] VALUES (@@SPID, GETDATE(),'Start') + + -- Score the loans and store them in a table + INSERT INTO [dbo].[LoanStatsPredictions] + EXEC sp_execute_external_script + @language = N'R', + @script = N' + rfModel <- unserialize(as.raw(model)); + OutputDataSet<-rxPredict(rfModel, data = InputDataSet, extraVarsToWrite = c("id")) + ', + @input_data_1 = @inquery, + @params = N'@model varbinary(max)', + @model = @model + + -- Log end of processing time + INSERT INTO [dbo].[RunTimeStats] VALUES (@@SPID, GETDATE(),'End') + +END +GO + + +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO + +-- Stored procedure to in +CREATE PROCEDURE [dbo].[ScoreLoansWhatIf] +@start bigint, +@end bigint, +@incr float +AS +BEGIN + + -- Declare the variables to get the input data and the scoring model + DECLARE @inquery nvarchar(max) = N'SELECT id,revol_util, (int_rate+ ' + CAST (@Incr as varchar(5)) + ') as int_rate, mths_since_last_record, annual_inc_joint, dti_joint, total_rec_prncp, all_util,is_bad FROM [dbo].[LoanStats] where [id] >= ' + CAST(@start as varchar(255)) + 'and [id] <= ' + CAST(@end as varchar(255)); + DECLARE @model varbinary(max) = (SELECT TOP 1 [model] FROM [dbo].[models]) + + -- Log beginning of processing time + INSERT INTO [dbo].[RunTimeStats] VALUES (@@SPID, GETDATE(),'Start') + + INSERT INTO [dbo].[LoanPredictionsWhatIf] + EXEC sp_execute_external_script + @language = N'R', + @script = N' + rfModel <- unserialize(as.raw(model)); + OutputDataSet<-rxPredict(rfModel, data = InputDataSet, extraVarsToWrite = c("id")) + ', + @input_data_1 = @inquery, + @params = N'@model varbinary(max)', + @model = @model + + -- Log end of processing time + INSERT INTO [dbo].[RunTimeStats] VALUES (@@SPID, GETDATE(),'End') + + +END + +GO + diff --git a/samples/features/r-services/Loan Classification/2 - ImportCSVData.ps1 b/samples/features/r-services/loan-classification/2 - ImportCSVData.ps1 similarity index 100% rename from samples/features/r-services/Loan Classification/2 - ImportCSVData.ps1 rename to samples/features/r-services/loan-classification/2 - ImportCSVData.ps1 diff --git a/samples/features/r-services/Loan Classification/3 - Create Columnstore Index.sql b/samples/features/r-services/loan-classification/3 - Create Columnstore Index.sql similarity index 95% rename from samples/features/r-services/Loan Classification/3 - Create Columnstore Index.sql rename to samples/features/r-services/loan-classification/3 - Create Columnstore Index.sql index 53a2f61d..ab8b9c29 100644 --- a/samples/features/r-services/Loan Classification/3 - Create Columnstore Index.sql +++ b/samples/features/r-services/loan-classification/3 - Create Columnstore Index.sql @@ -1,19 +1,19 @@ -USE [LendingClub] -GO - -UPDATE [dbo].[LoanStats] -SET [is_bad] = (CASE WHEN loan_status IN ('Late (16-30 days)', 'Late (31-120 days)', 'Default', 'Charged Off') THEN 1 ELSE 0 END); - -CREATE NONCLUSTERED COLUMNSTORE INDEX [ncci_LoanStats] ON [dbo].[LoanStats] -( - [revol_util], - [int_rate], - [mths_since_last_record], - [annual_inc_joint], - [dti_joint], - [total_rec_prncp], - [all_util], - [is_bad] -)WITH (COMPRESSION_DELAY = 0, MAXDOP = 1) ON [PRIMARY]; -GO - +USE [LendingClub] +GO + +UPDATE [dbo].[LoanStats] +SET [is_bad] = (CASE WHEN loan_status IN ('Late (16-30 days)', 'Late (31-120 days)', 'Default', 'Charged Off') THEN 1 ELSE 0 END); + +CREATE NONCLUSTERED COLUMNSTORE INDEX [ncci_LoanStats] ON [dbo].[LoanStats] +( + [revol_util], + [int_rate], + [mths_since_last_record], + [annual_inc_joint], + [dti_joint], + [total_rec_prncp], + [all_util], + [is_bad] +)WITH (COMPRESSION_DELAY = 0, MAXDOP = 1) ON [PRIMARY]; +GO + diff --git a/samples/features/r-services/Loan Classification/4 - Create Model.sql b/samples/features/r-services/loan-classification/4 - Create Model.sql similarity index 97% rename from samples/features/r-services/Loan Classification/4 - Create Model.sql rename to samples/features/r-services/loan-classification/4 - Create Model.sql index 3b75969a..e1833ca3 100644 --- a/samples/features/r-services/Loan Classification/4 - Create Model.sql +++ b/samples/features/r-services/loan-classification/4 - Create Model.sql @@ -1,24 +1,24 @@ -USE [LendingClub] -GO - -SET ANSI_NULLS ON -GO - -SET QUOTED_IDENTIFIER ON -GO - -CREATE TABLE [dbo].[models]( - [model] [varbinary](max) NOT NULL -) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]; - -GO - -INSERT INTO [dbo].[models] -EXEC sp_execute_external_script - @language = N'R', - @script = N' - randomForestObj <- rxDForest(is_bad ~ revol_util + int_rate + mths_since_last_record + annual_inc_joint + dti_joint + total_rec_prncp + all_util, InputDataSet) - model <- data.frame(payload = as.raw(serialize(randomForestObj, connection=NULL))) - ', - @input_data_1 = N'SELECT revol_util, int_rate, mths_since_last_record, annual_inc_joint, dti_joint, total_rec_prncp, all_util,is_bad FROM [dbo].[LoanStats] WHERE (ABS(CAST((BINARY_CHECKSUM(id, NEWID())) as int)) % 100) < 75', - @output_data_1_name = N'model'; +USE [LendingClub] +GO + +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE TABLE [dbo].[models]( + [model] [varbinary](max) NOT NULL +) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]; + +GO + +INSERT INTO [dbo].[models] +EXEC sp_execute_external_script + @language = N'R', + @script = N' + randomForestObj <- rxDForest(is_bad ~ revol_util + int_rate + mths_since_last_record + annual_inc_joint + dti_joint + total_rec_prncp + all_util, InputDataSet) + model <- data.frame(payload = as.raw(serialize(randomForestObj, connection=NULL))) + ', + @input_data_1 = N'SELECT revol_util, int_rate, mths_since_last_record, annual_inc_joint, dti_joint, total_rec_prncp, all_util,is_bad FROM [dbo].[LoanStats] WHERE (ABS(CAST((BINARY_CHECKSUM(id, NEWID())) as int)) % 100) < 75', + @output_data_1_name = N'model'; diff --git a/samples/features/r-services/Loan Classification/5 - Resource Governor Config.sql b/samples/features/r-services/loan-classification/5 - Resource Governor Config.sql similarity index 93% rename from samples/features/r-services/Loan Classification/5 - Resource Governor Config.sql rename to samples/features/r-services/loan-classification/5 - Resource Governor Config.sql index 53dbf23e..97b614f1 100644 --- a/samples/features/r-services/Loan Classification/5 - Resource Governor Config.sql +++ b/samples/features/r-services/loan-classification/5 - Resource Governor Config.sql @@ -1,46 +1,46 @@ -create external resource pool "lcerp1" with (affinity numanode = (0)); - -create external resource pool "lcerp2" with (affinity numanode = (1)); - - - -create resource pool "lcrp1" with (affinity numanode = (0)); - -create resource pool "lcrp2" with (affinity numanode = (1)); - - - -create workload group "rg0" using "lcrp1", external "lcerp1"; - -create workload group "rg1" using "lcrp2", external "lcerp2"; - - - -USE [master] - -GO - -SET ANSI_NULLS ON - -GO - -SET QUOTED_IDENTIFIER ON - -GO - -CREATE function [dbo].[assign_external_resource_pool]() - -returns sysname - -with schemabinding - -as - -begin - -return concat('rg', @@SPID%2); - -end; - -GO - +create external resource pool "lcerp1" with (affinity numanode = (0)); + +create external resource pool "lcerp2" with (affinity numanode = (1)); + + + +create resource pool "lcrp1" with (affinity numanode = (0)); + +create resource pool "lcrp2" with (affinity numanode = (1)); + + + +create workload group "rg0" using "lcrp1", external "lcerp1"; + +create workload group "rg1" using "lcrp2", external "lcerp2"; + + + +USE [master] + +GO + +SET ANSI_NULLS ON + +GO + +SET QUOTED_IDENTIFIER ON + +GO + +CREATE function [dbo].[assign_external_resource_pool]() + +returns sysname + +with schemabinding + +as + +begin + +return concat('rg', @@SPID%2); + +end; + +GO + diff --git a/samples/features/r-services/Loan Classification/6 - Score Loans.ps1 b/samples/features/r-services/loan-classification/6 - Score Loans.ps1 similarity index 96% rename from samples/features/r-services/Loan Classification/6 - Score Loans.ps1 rename to samples/features/r-services/loan-classification/6 - Score Loans.ps1 index 09333de3..103a8314 100644 --- a/samples/features/r-services/Loan Classification/6 - Score Loans.ps1 +++ b/samples/features/r-services/loan-classification/6 - Score Loans.ps1 @@ -1,48 +1,48 @@ -cls -# Create a while loop to start the SQL jobs to execute scoring procedure in parallel - -$StartCtr = 1 -$Increment = 250000 -$EndCtr = $Increment -$FinalCount = 1195907 -$vServerName = $env:computername -$vDatabaseName = "LendingClub" -$count = "{0:N0}" -f $FinalCount - -Write-Host "Performing clean-up to start new scoring run...." -ForegroundColor Yellow - -# Start Cleanup -Invoke-Sqlcmd -ServerInstance $vServerName -Database $vDatabaseName -Query "delete from [LoanStatsPredictions];delete from Runtimestats;checkpoint;" - -Write-Host "Starting parallel jobs to score " $count "loans" -ForegroundColor Yellow - -while ($EndCtr -le $FinalCount) -{ - $SqlScript = [ScriptBlock]::Create("Invoke-Sqlcmd -ServerInstance `"" + $vServerName + "`" -Query `"EXEC [dbo].[ScoreLoans] " + $StartCtr + "," + $EndCtr + "`" -Database `"$vDatabaseName`"") - Start-Job -ScriptBlock $SqlScript - $StartCtr += $Increment - $EndCtr += $Increment -} - -# Wait till jobs complete -while (Get-Job -State Running) -{ - - Start-Sleep 1 -} - - -# Find out duration -$duration = Invoke-Sqlcmd -ServerInstance $vServerName -Database $vDatabaseName -Query "select DATEDIFF(s,MIN (Runtime), MAX(Runtime)) as RuntimeSeconds from dbo.RuntimeStats;" - -Write-Host "`n" - -$rate = "{0:N2}" -f ($FinalCount/$duration.RuntimeSeconds) - -Write-Host "Completed scoring" $count "loans in" $duration.RuntimeSeconds "seconds at" $rate "loans/sec." -ForegroundColor Green - -# Remove Jobs -Get-Job | Remove-Job - - - +cls +# Create a while loop to start the SQL jobs to execute scoring procedure in parallel + +$StartCtr = 1 +$Increment = 250000 +$EndCtr = $Increment +$FinalCount = 1195907 +$vServerName = $env:computername +$vDatabaseName = "LendingClub" +$count = "{0:N0}" -f $FinalCount + +Write-Host "Performing clean-up to start new scoring run...." -ForegroundColor Yellow + +# Start Cleanup +Invoke-Sqlcmd -ServerInstance $vServerName -Database $vDatabaseName -Query "delete from [LoanStatsPredictions];delete from Runtimestats;checkpoint;" + +Write-Host "Starting parallel jobs to score " $count "loans" -ForegroundColor Yellow + +while ($EndCtr -le $FinalCount) +{ + $SqlScript = [ScriptBlock]::Create("Invoke-Sqlcmd -ServerInstance `"" + $vServerName + "`" -Query `"EXEC [dbo].[ScoreLoans] " + $StartCtr + "," + $EndCtr + "`" -Database `"$vDatabaseName`"") + Start-Job -ScriptBlock $SqlScript + $StartCtr += $Increment + $EndCtr += $Increment +} + +# Wait till jobs complete +while (Get-Job -State Running) +{ + + Start-Sleep 1 +} + + +# Find out duration +$duration = Invoke-Sqlcmd -ServerInstance $vServerName -Database $vDatabaseName -Query "select DATEDIFF(s,MIN (Runtime), MAX(Runtime)) as RuntimeSeconds from dbo.RuntimeStats;" + +Write-Host "`n" + +$rate = "{0:N2}" -f ($FinalCount/$duration.RuntimeSeconds) + +Write-Host "Completed scoring" $count "loans in" $duration.RuntimeSeconds "seconds at" $rate "loans/sec." -ForegroundColor Green + +# Remove Jobs +Get-Job | Remove-Job + + + diff --git a/samples/features/r-services/Loan Classification/7 - WhatIf.ps1 b/samples/features/r-services/loan-classification/7 - WhatIf.ps1 similarity index 96% rename from samples/features/r-services/Loan Classification/7 - WhatIf.ps1 rename to samples/features/r-services/loan-classification/7 - WhatIf.ps1 index d04f1474..73bc1572 100644 --- a/samples/features/r-services/Loan Classification/7 - WhatIf.ps1 +++ b/samples/features/r-services/loan-classification/7 - WhatIf.ps1 @@ -1,64 +1,64 @@ -cls -# Create a while loop to start the SQL jobs to execute scoring procedure in parallel - -# Counter values -$StartCtr = 1 -$Increment = 250000 -$EndCtr = $Increment -$FinalCount = 1195907 - -# Server name -$vServerName = $env:computername -# Database name -$vDatabaseName = "LendingClub" -# Formatting the string -$count = "{0:N0}" -f $FinalCount - -# Start verbose output -Write-Host "Performing clean-up to start new scoring run...." -ForegroundColor Yellow - -# Start Cleanup -Invoke-Sqlcmd -ServerInstance $vServerName -Database $vDatabaseName -Query "delete from [LoanPredictionsWhatIf];delete from Runtimestats;checkpoint;" - - -# Get What-If scenario -Write-Host "Please provide an increase in the Interest Rate that you want to model with: " -$IntRate = Read-Host -Write-Host "Requested change: " $IntRate -ForegroundColor Yellow - -# Store requested rate in database -$SqlScript ="UPDATE WhatIf SET Rate = " + $IntRate -Invoke-Sqlcmd -ServerInstance $vServerName -Database $vDatabaseName -Query $SqlScript - -Write-Host "Starting parallel jobs to score " $count "loans" -ForegroundColor Yellow - -while ($EndCtr -le $FinalCount) -{ - $SqlScript = [ScriptBlock]::Create("Invoke-Sqlcmd -ServerInstance `"" + $vServerName + "`" -Query `"EXEC [dbo].[ScoreLoansWhatIf] " + $StartCtr + "," + $EndCtr + "," + $IntRate + "`" -Database `"$vDatabaseName`"") - Start-Job -ScriptBlock $SqlScript - $StartCtr += $Increment - $EndCtr += $Increment -} - -# Wait till jobs complete -while (Get-Job -State Running) -{ - - Start-Sleep 1 -} - - -# Find out duration -$duration = Invoke-Sqlcmd -ServerInstance $vServerName -Database $vDatabaseName -Query "select DATEDIFF(s,MIN (Runtime), MAX(Runtime)) as RuntimeSeconds from dbo.RuntimeStats;" - -Write-Host "`n" - -$rate = "{0:N2}" -f ($FinalCount/$duration.RuntimeSeconds) - -Write-Host "Completed scoring" $count "loans in" $duration.RuntimeSeconds "seconds at" $rate "loans/sec." -ForegroundColor Green - -# Remove Jobs -Get-Job | Remove-Job - - - +cls +# Create a while loop to start the SQL jobs to execute scoring procedure in parallel + +# Counter values +$StartCtr = 1 +$Increment = 250000 +$EndCtr = $Increment +$FinalCount = 1195907 + +# Server name +$vServerName = $env:computername +# Database name +$vDatabaseName = "LendingClub" +# Formatting the string +$count = "{0:N0}" -f $FinalCount + +# Start verbose output +Write-Host "Performing clean-up to start new scoring run...." -ForegroundColor Yellow + +# Start Cleanup +Invoke-Sqlcmd -ServerInstance $vServerName -Database $vDatabaseName -Query "delete from [LoanPredictionsWhatIf];delete from Runtimestats;checkpoint;" + + +# Get What-If scenario +Write-Host "Please provide an increase in the Interest Rate that you want to model with: " +$IntRate = Read-Host +Write-Host "Requested change: " $IntRate -ForegroundColor Yellow + +# Store requested rate in database +$SqlScript ="UPDATE WhatIf SET Rate = " + $IntRate +Invoke-Sqlcmd -ServerInstance $vServerName -Database $vDatabaseName -Query $SqlScript + +Write-Host "Starting parallel jobs to score " $count "loans" -ForegroundColor Yellow + +while ($EndCtr -le $FinalCount) +{ + $SqlScript = [ScriptBlock]::Create("Invoke-Sqlcmd -ServerInstance `"" + $vServerName + "`" -Query `"EXEC [dbo].[ScoreLoansWhatIf] " + $StartCtr + "," + $EndCtr + "," + $IntRate + "`" -Database `"$vDatabaseName`"") + Start-Job -ScriptBlock $SqlScript + $StartCtr += $Increment + $EndCtr += $Increment +} + +# Wait till jobs complete +while (Get-Job -State Running) +{ + + Start-Sleep 1 +} + + +# Find out duration +$duration = Invoke-Sqlcmd -ServerInstance $vServerName -Database $vDatabaseName -Query "select DATEDIFF(s,MIN (Runtime), MAX(Runtime)) as RuntimeSeconds from dbo.RuntimeStats;" + +Write-Host "`n" + +$rate = "{0:N2}" -f ($FinalCount/$duration.RuntimeSeconds) + +Write-Host "Completed scoring" $count "loans in" $duration.RuntimeSeconds "seconds at" $rate "loans/sec." -ForegroundColor Green + +# Remove Jobs +Get-Job | Remove-Job + + + diff --git a/samples/features/r-services/Loan Classification/README.md b/samples/features/r-services/loan-classification/README.md similarity index 100% rename from samples/features/r-services/Loan Classification/README.md rename to samples/features/r-services/loan-classification/README.md diff --git a/samples/features/r-services/Implementing Predictive Analytics/Readme.md b/samples/features/r-services/predictive-analytics/Readme.md similarity index 99% rename from samples/features/r-services/Implementing Predictive Analytics/Readme.md rename to samples/features/r-services/predictive-analytics/Readme.md index 9c506b04..0d7ae275 100644 --- a/samples/features/r-services/Implementing Predictive Analytics/Readme.md +++ b/samples/features/r-services/predictive-analytics/Readme.md @@ -1,51 +1,51 @@ -Implementing Predictive Analytics in Your Applications -============================================================ - -Predictive analytics are a powerful way to add intelligence to your application, it enables you to predict outcomes against data that is new to your application. The Microsoft data platform provides numerous ways you can add predictive analytics to your applications - -What is predictive analytics? -------------------------------- -Before we get into the implementation, let’s address a fundamental question—**what is predictive analytics?** At their core, predictive tasks are those that predict one value given a set of other values as input. In other words, predictive tasks learn (or are taught) how to make predictions. This learning is captured in a model by an algorithm. Think of the model as the way the learnings are compactly summarized. When you want to make a prediction, you invoke a prediction operation and provide the model as one of the inputs, along with the input values against which you want to form a prediction. Predictive analytics is the act of applying prediction (and your model) to your data to gain new insights. - -So, **what are some examples of predictive analytics?** These fall out into two basic categories. You have _prediction that aims to predict the class (or category) of something_. For example, you can have single class classification that tries to predict if an email is spam or not spam—so the class is either “spam” or “not spam”. You can also have multi-class classification, that predicts an outcome from a set of possible outcomes. For example, you can have a multi-class classification that predicts if a consumer is at “high risk”, “moderate risk”, or “low risk” of default on a loan. - -You also have _numeric prediction_. Instead of trying to predict a class from a fixed set of options, numeric prediction tries to predict a numeric value from a continuous range of numbers. For example, you might try to predict how long of a delay in minutes a flight will experience or the currency value of a particular stock in the stock market. - -Prediction on the Microsoft Data Platform ----------------------------------------------- -The Microsoft Data Platform provide numerous ways you can build predictive models that you can then integrate into your application. The following diagram summarizes the options: - -![Alternatives to train and use a model](imgs/UseModelForPrediction.png "Model Train and use") - -As you can infer from the diagram, the act of incorporating predictive analytics into your applications involves two major phases: model creation and model operationalization. Conceptually, these are very simple to understand. - -**Model Creation:** During model creation, you train your predictive model (by showing it sample data along with the outcomes) and test that it works (at least that it predicts results better than random chance would). You save this model so you can use it later when you want to make predictions against new data. - -**Model Operationalization:** During model operationalization, you are implementing predictions that use your model in whatever hosting environment (such as a web service) makes sense for integration with your application. In other words, operationalization is how you add predictive analytics to your application. - -Options for Model Creation ------------------------------ -Let’s begin by understanding the various ways you can train and test your model. When creating your model, you can train your model locally. This is amounts to authoring and running R or Python scripts on your development workstation. For example, you might use the integrated development environment R GUI (a component in Microsoft R Open) or R Tools for Visual Studio to author your R scripts that train your model, help you test it and visualize the results. - -Alternately, the training can be done using resources that are remote to your development workstation. The Microsoft Data Platform offers the following options for this: - -* **Azure Machine Learning (Azure ML):** Azure ML enables you to design predictive experiments (referred to as scoring experiments) using its browser based Machine Learning Studio. The visual drag-and-drop experience is like designing a flowchart, where each box of the flowchart is called a “module”. Modules can retrieve data, transform data, process data, create predictive models and evaluate their predictive performance. There are numerous built in modules that let you define and run custom script code written in R or Python as desired. - -* **HDInsight:** HDInsight provides numerous ways you can train predictive models using a cluster of servers running in Azure. With R Server on Spark and R Server on Hadoop, you author R scripts whose execution runs across the cluster to train (and test) your model. If you deploy an HDInsight with Spark, you can use Spark ML to program the training and testing models using Scala, Java, Python or R. Generally, the data used to train models in HDInsight comes from a form of highly scalable block storage such as HDFS, Azure Data Lake Store or Azure Storage Blobs. - -* **SQL R Services:** SQL in R Services enable you to train and test predictive models in the context of SQL Server 2016. You author T-SQL procedures that contain embedded R scripts, and the SQL Server database engine takes care of the execution. Because it executes in the context of SQL Server, your models can be easily trained against data stored within tables within your database. - -Option for Model Operationalization ---------------------------------------- -The Microsoft Data Platform also provide multiple ways of adding predictive analytics to an application. As you can see in the diagram, while there are many ways to train a model there tend to be only a few practical ways to use the model from an application. - -* **Invoke Predict within a Script:** When running within a local environment, you can easily use the trained model as input into your predictive script. - -* **Invoke Predictive Web Service:** When running in a remote environment, a common approach is to encapsulate the call to prediction in a web service/Rest API operation that is readily invoked from an application. For Azure ML, this is as easy as a few clicks to deploy a predictive experiment as a web service. For HDInsight, this amounts to exporting your trained model to a file and importing the model into a compatible host such a Microsoft’s DeployR (for models created with R Server on Spark or Hadoop), which wraps a web services layer around a prediction script written in R. - -* **Invoke a Predictive Store Procedure:** When using SQL R Services, you can package the code that invokes prediction using your model within a stored procedure. Therefore, integrating a prediction into your application becomes a matter of executing a stored a procedure in SQL Server—something that most applications can easily accomplish regardless of whether they are written in .NET, node.js, Java... - -While each approach has its merits, in the accompanying lab, we’ll examine how to augment a node.js application with predictive analytics using this last approach that invokes a predictive stored procedure running in SQL Server 2016. - -**Done with the intro?** +Implementing Predictive Analytics in Your Applications +============================================================ + +Predictive analytics are a powerful way to add intelligence to your application, it enables you to predict outcomes against data that is new to your application. The Microsoft data platform provides numerous ways you can add predictive analytics to your applications + +What is predictive analytics? +------------------------------- +Before we get into the implementation, let’s address a fundamental question—**what is predictive analytics?** At their core, predictive tasks are those that predict one value given a set of other values as input. In other words, predictive tasks learn (or are taught) how to make predictions. This learning is captured in a model by an algorithm. Think of the model as the way the learnings are compactly summarized. When you want to make a prediction, you invoke a prediction operation and provide the model as one of the inputs, along with the input values against which you want to form a prediction. Predictive analytics is the act of applying prediction (and your model) to your data to gain new insights. + +So, **what are some examples of predictive analytics?** These fall out into two basic categories. You have _prediction that aims to predict the class (or category) of something_. For example, you can have single class classification that tries to predict if an email is spam or not spam—so the class is either “spam” or “not spam”. You can also have multi-class classification, that predicts an outcome from a set of possible outcomes. For example, you can have a multi-class classification that predicts if a consumer is at “high risk”, “moderate risk”, or “low risk” of default on a loan. + +You also have _numeric prediction_. Instead of trying to predict a class from a fixed set of options, numeric prediction tries to predict a numeric value from a continuous range of numbers. For example, you might try to predict how long of a delay in minutes a flight will experience or the currency value of a particular stock in the stock market. + +Prediction on the Microsoft Data Platform +---------------------------------------------- +The Microsoft Data Platform provide numerous ways you can build predictive models that you can then integrate into your application. The following diagram summarizes the options: + +![Alternatives to train and use a model](imgs/UseModelForPrediction.png "Model Train and use") + +As you can infer from the diagram, the act of incorporating predictive analytics into your applications involves two major phases: model creation and model operationalization. Conceptually, these are very simple to understand. + +**Model Creation:** During model creation, you train your predictive model (by showing it sample data along with the outcomes) and test that it works (at least that it predicts results better than random chance would). You save this model so you can use it later when you want to make predictions against new data. + +**Model Operationalization:** During model operationalization, you are implementing predictions that use your model in whatever hosting environment (such as a web service) makes sense for integration with your application. In other words, operationalization is how you add predictive analytics to your application. + +Options for Model Creation +----------------------------- +Let’s begin by understanding the various ways you can train and test your model. When creating your model, you can train your model locally. This is amounts to authoring and running R or Python scripts on your development workstation. For example, you might use the integrated development environment R GUI (a component in Microsoft R Open) or R Tools for Visual Studio to author your R scripts that train your model, help you test it and visualize the results. + +Alternately, the training can be done using resources that are remote to your development workstation. The Microsoft Data Platform offers the following options for this: + +* **Azure Machine Learning (Azure ML):** Azure ML enables you to design predictive experiments (referred to as scoring experiments) using its browser based Machine Learning Studio. The visual drag-and-drop experience is like designing a flowchart, where each box of the flowchart is called a “module”. Modules can retrieve data, transform data, process data, create predictive models and evaluate their predictive performance. There are numerous built in modules that let you define and run custom script code written in R or Python as desired. + +* **HDInsight:** HDInsight provides numerous ways you can train predictive models using a cluster of servers running in Azure. With R Server on Spark and R Server on Hadoop, you author R scripts whose execution runs across the cluster to train (and test) your model. If you deploy an HDInsight with Spark, you can use Spark ML to program the training and testing models using Scala, Java, Python or R. Generally, the data used to train models in HDInsight comes from a form of highly scalable block storage such as HDFS, Azure Data Lake Store or Azure Storage Blobs. + +* **SQL R Services:** SQL in R Services enable you to train and test predictive models in the context of SQL Server 2016. You author T-SQL procedures that contain embedded R scripts, and the SQL Server database engine takes care of the execution. Because it executes in the context of SQL Server, your models can be easily trained against data stored within tables within your database. + +Option for Model Operationalization +--------------------------------------- +The Microsoft Data Platform also provide multiple ways of adding predictive analytics to an application. As you can see in the diagram, while there are many ways to train a model there tend to be only a few practical ways to use the model from an application. + +* **Invoke Predict within a Script:** When running within a local environment, you can easily use the trained model as input into your predictive script. + +* **Invoke Predictive Web Service:** When running in a remote environment, a common approach is to encapsulate the call to prediction in a web service/Rest API operation that is readily invoked from an application. For Azure ML, this is as easy as a few clicks to deploy a predictive experiment as a web service. For HDInsight, this amounts to exporting your trained model to a file and importing the model into a compatible host such a Microsoft’s DeployR (for models created with R Server on Spark or Hadoop), which wraps a web services layer around a prediction script written in R. + +* **Invoke a Predictive Store Procedure:** When using SQL R Services, you can package the code that invokes prediction using your model within a stored procedure. Therefore, integrating a prediction into your application becomes a matter of executing a stored a procedure in SQL Server—something that most applications can easily accomplish regardless of whether they are written in .NET, node.js, Java... + +While each approach has its merits, in the accompanying lab, we’ll examine how to augment a node.js application with predictive analytics using this last approach that invokes a predictive stored procedure running in SQL Server 2016. + +**Done with the intro?** [Start the lab](scripts/Lab.md) \ No newline at end of file diff --git a/samples/features/r-services/Implementing Predictive Analytics/imgs/UseModelForPrediction.png b/samples/features/r-services/predictive-analytics/imgs/UseModelForPrediction.png similarity index 100% rename from samples/features/r-services/Implementing Predictive Analytics/imgs/UseModelForPrediction.png rename to samples/features/r-services/predictive-analytics/imgs/UseModelForPrediction.png diff --git a/samples/features/r-services/Implementing Predictive Analytics/scripts/Create Database taxidata.sql b/samples/features/r-services/predictive-analytics/scripts/Create Database taxidata.sql similarity index 96% rename from samples/features/r-services/Implementing Predictive Analytics/scripts/Create Database taxidata.sql rename to samples/features/r-services/predictive-analytics/scripts/Create Database taxidata.sql index 33ab4638..725cf3cc 100644 --- a/samples/features/r-services/Implementing Predictive Analytics/scripts/Create Database taxidata.sql +++ b/samples/features/r-services/predictive-analytics/scripts/Create Database taxidata.sql @@ -1,2 +1,2 @@ -CREATE DATABASE taxidata; +CREATE DATABASE taxidata; GO \ No newline at end of file diff --git a/samples/features/r-services/Implementing Predictive Analytics/scripts/Create Function fnEngineerFeatures.sql b/samples/features/r-services/predictive-analytics/scripts/Create Function fnEngineerFeatures.sql similarity index 94% rename from samples/features/r-services/Implementing Predictive Analytics/scripts/Create Function fnEngineerFeatures.sql rename to samples/features/r-services/predictive-analytics/scripts/Create Function fnEngineerFeatures.sql index b8d656fe..2d811fa3 100644 --- a/samples/features/r-services/Implementing Predictive Analytics/scripts/Create Function fnEngineerFeatures.sql +++ b/samples/features/r-services/predictive-analytics/scripts/Create Function fnEngineerFeatures.sql @@ -1,24 +1,24 @@ -USE [taxidata] -GO - - -CREATE FUNCTION [dbo].[fnEngineerFeatures] ( -@passenger_count int = 0, -@trip_distance float = 0, -@trip_time_in_secs int = 0, -@direct_distance float = 0) -RETURNS TABLE -AS - RETURN - ( - - SELECT - @passenger_count AS passenger_count, - @trip_distance AS trip_distance, - @trip_time_in_secs AS trip_time_in_secs, - @direct_distance as direct_distance - ) - -GO - - +USE [taxidata] +GO + + +CREATE FUNCTION [dbo].[fnEngineerFeatures] ( +@passenger_count int = 0, +@trip_distance float = 0, +@trip_time_in_secs int = 0, +@direct_distance float = 0) +RETURNS TABLE +AS + RETURN + ( + + SELECT + @passenger_count AS passenger_count, + @trip_distance AS trip_distance, + @trip_time_in_secs AS trip_time_in_secs, + @direct_distance as direct_distance + ) + +GO + + diff --git a/samples/features/r-services/Implementing Predictive Analytics/scripts/Create Procedure PredictTip.sql b/samples/features/r-services/predictive-analytics/scripts/Create Procedure PredictTip.sql similarity index 100% rename from samples/features/r-services/Implementing Predictive Analytics/scripts/Create Procedure PredictTip.sql rename to samples/features/r-services/predictive-analytics/scripts/Create Procedure PredictTip.sql diff --git a/samples/features/r-services/Implementing Predictive Analytics/scripts/Create Procedure TrainTipPredictionModel.sql b/samples/features/r-services/predictive-analytics/scripts/Create Procedure TrainTipPredictionModel.sql similarity index 96% rename from samples/features/r-services/Implementing Predictive Analytics/scripts/Create Procedure TrainTipPredictionModel.sql rename to samples/features/r-services/predictive-analytics/scripts/Create Procedure TrainTipPredictionModel.sql index c1585626..4f405ed5 100644 --- a/samples/features/r-services/Implementing Predictive Analytics/scripts/Create Procedure TrainTipPredictionModel.sql +++ b/samples/features/r-services/predictive-analytics/scripts/Create Procedure TrainTipPredictionModel.sql @@ -1,33 +1,33 @@ -use taxidata -go - -CREATE PROCEDURE [dbo].[TrainTipPredictionModel] -AS -BEGIN - DECLARE @inquery nvarchar(max) = N' - select tipped, passenger_count, trip_time_in_secs, trip_distance, direct_distance - from nyctaxi_features -' - - --delete previous stored models - truncate table dbo.nyc_taxi_models - - -- Insert the trained model into a database table - INSERT INTO nyc_taxi_models - EXEC sp_execute_external_script - @language = N'R', - @script = N' - - ## Create model - logitObj <- rxLogit(tipped ~ passenger_count + trip_distance + trip_time_in_secs + direct_distance, data = InputDataSet) - - - ## Serialize model and put it in data frame - trained_model <- data.frame(model=as.raw(serialize(logitObj, NULL))); - ', - @input_data_1 = @inquery, - @output_data_1_name = N'trained_model' - ; - -END +use taxidata +go + +CREATE PROCEDURE [dbo].[TrainTipPredictionModel] +AS +BEGIN + DECLARE @inquery nvarchar(max) = N' + select tipped, passenger_count, trip_time_in_secs, trip_distance, direct_distance + from nyctaxi_features +' + + --delete previous stored models + truncate table dbo.nyc_taxi_models + + -- Insert the trained model into a database table + INSERT INTO nyc_taxi_models + EXEC sp_execute_external_script + @language = N'R', + @script = N' + + ## Create model + logitObj <- rxLogit(tipped ~ passenger_count + trip_distance + trip_time_in_secs + direct_distance, data = InputDataSet) + + + ## Serialize model and put it in data frame + trained_model <- data.frame(model=as.raw(serialize(logitObj, NULL))); + ', + @input_data_1 = @inquery, + @output_data_1_name = N'trained_model' + ; + +END GO \ No newline at end of file diff --git a/samples/features/r-services/Implementing Predictive Analytics/scripts/Create nyc_taxi_models Table.sql b/samples/features/r-services/predictive-analytics/scripts/Create nyc_taxi_models Table.sql similarity index 93% rename from samples/features/r-services/Implementing Predictive Analytics/scripts/Create nyc_taxi_models Table.sql rename to samples/features/r-services/predictive-analytics/scripts/Create nyc_taxi_models Table.sql index 18a2f1e8..d9beb988 100644 --- a/samples/features/r-services/Implementing Predictive Analytics/scripts/Create nyc_taxi_models Table.sql +++ b/samples/features/r-services/predictive-analytics/scripts/Create nyc_taxi_models Table.sql @@ -1,9 +1,9 @@ -USE [taxidata] -GO - -CREATE TABLE [dbo].[nyc_taxi_models]( - [model] [varbinary](max) NOT NULL -) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] -GO - - +USE [taxidata] +GO + +CREATE TABLE [dbo].[nyc_taxi_models]( + [model] [varbinary](max) NOT NULL +) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] +GO + + diff --git a/samples/features/r-services/Implementing Predictive Analytics/scripts/Create nyctaxi_features Table.sql b/samples/features/r-services/predictive-analytics/scripts/Create nyctaxi_features Table.sql similarity index 94% rename from samples/features/r-services/Implementing Predictive Analytics/scripts/Create nyctaxi_features Table.sql rename to samples/features/r-services/predictive-analytics/scripts/Create nyctaxi_features Table.sql index 6e8e9668..920c039a 100644 --- a/samples/features/r-services/Implementing Predictive Analytics/scripts/Create nyctaxi_features Table.sql +++ b/samples/features/r-services/predictive-analytics/scripts/Create nyctaxi_features Table.sql @@ -1,15 +1,15 @@ -USE [taxidata] -GO - -CREATE TABLE [dbo].[nyctaxi_features]( - [passenger_count] [int] NULL, - [trip_time_in_secs] [bigint] NULL, - [trip_distance] [float] NULL, - [direct_distance] [float] NULL, - [tip_amount] [float] NULL, - [tipped] [int] NULL -) ON [PRIMARY] - -GO - - +USE [taxidata] +GO + +CREATE TABLE [dbo].[nyctaxi_features]( + [passenger_count] [int] NULL, + [trip_time_in_secs] [bigint] NULL, + [trip_distance] [float] NULL, + [direct_distance] [float] NULL, + [tip_amount] [float] NULL, + [tipped] [int] NULL +) ON [PRIMARY] + +GO + + diff --git a/samples/features/r-services/Implementing Predictive Analytics/scripts/EndToEndRScript.r b/samples/features/r-services/predictive-analytics/scripts/EndToEndRScript.r similarity index 98% rename from samples/features/r-services/Implementing Predictive Analytics/scripts/EndToEndRScript.r rename to samples/features/r-services/predictive-analytics/scripts/EndToEndRScript.r index 09acafed..65cbf34f 100644 --- a/samples/features/r-services/Implementing Predictive Analytics/scripts/EndToEndRScript.r +++ b/samples/features/r-services/predictive-analytics/scripts/EndToEndRScript.r @@ -1,23 +1,23 @@ -## Just in case you want to go through the steps on an R tool like (RGui, RStudio or R Tools for VS) -##this script uses rpart instead of rxlogit -## these are the step by step to reproduce the lab - -install.packages("RODBC") -library(RODBC) - -##Connect to SQL Server 2016, assumes a Windows Authentication method -dbhandle <- odbcDriverConnect('driver={SQL Server};server=;database=taxidata;trusted_connection=true') - -##Run the query to brin the data we'll use to create the model -res <- sqlQuery(dbhandle, 'select tipped, passenger_count, trip_time_in_secs, trip_distance, direct_distance from nyctaxi_features') - -##Create the model... -model <- rxLogit(tipped ~ passenger_count + trip_distance + trip_time_in_secs + direct_distance, res) -summary(model) - -##Now, let's create the frame with the parameters for the prediction -prediction_parameters <- data.frame(passenger_count = 1, trip_time_in_secs = 631, trip_distance = 2.5, direct_distance = 2) - -##predict -OutputDataFrame <- rxPredict(model, prediction_parameters, outData = NULL, predVarNames = "Score", type = "response", writeModelVars = FALSE, overwrite = TRUE) +## Just in case you want to go through the steps on an R tool like (RGui, RStudio or R Tools for VS) +##this script uses rpart instead of rxlogit +## these are the step by step to reproduce the lab + +install.packages("RODBC") +library(RODBC) + +##Connect to SQL Server 2016, assumes a Windows Authentication method +dbhandle <- odbcDriverConnect('driver={SQL Server};server=;database=taxidata;trusted_connection=true') + +##Run the query to brin the data we'll use to create the model +res <- sqlQuery(dbhandle, 'select tipped, passenger_count, trip_time_in_secs, trip_distance, direct_distance from nyctaxi_features') + +##Create the model... +model <- rxLogit(tipped ~ passenger_count + trip_distance + trip_time_in_secs + direct_distance, res) +summary(model) + +##Now, let's create the frame with the parameters for the prediction +prediction_parameters <- data.frame(passenger_count = 1, trip_time_in_secs = 631, trip_distance = 2.5, direct_distance = 2) + +##predict +OutputDataFrame <- rxPredict(model, prediction_parameters, outData = NULL, predVarNames = "Score", type = "response", writeModelVars = FALSE, overwrite = TRUE) OutputDataFrame \ No newline at end of file diff --git a/samples/features/r-services/Implementing Predictive Analytics/scripts/Exec PredictTip.sql b/samples/features/r-services/predictive-analytics/scripts/Exec PredictTip.sql similarity index 100% rename from samples/features/r-services/Implementing Predictive Analytics/scripts/Exec PredictTip.sql rename to samples/features/r-services/predictive-analytics/scripts/Exec PredictTip.sql diff --git a/samples/features/r-services/Implementing Predictive Analytics/scripts/Exec TrainTipPredictionModel.sql b/samples/features/r-services/predictive-analytics/scripts/Exec TrainTipPredictionModel.sql similarity index 100% rename from samples/features/r-services/Implementing Predictive Analytics/scripts/Exec TrainTipPredictionModel.sql rename to samples/features/r-services/predictive-analytics/scripts/Exec TrainTipPredictionModel.sql diff --git a/samples/features/r-services/Implementing Predictive Analytics/scripts/Lab.md b/samples/features/r-services/predictive-analytics/scripts/Lab.md similarity index 97% rename from samples/features/r-services/Implementing Predictive Analytics/scripts/Lab.md rename to samples/features/r-services/predictive-analytics/scripts/Lab.md index 419afd88..8c954e04 100644 --- a/samples/features/r-services/Implementing Predictive Analytics/scripts/Lab.md +++ b/samples/features/r-services/predictive-analytics/scripts/Lab.md @@ -1,358 +1,358 @@ -# Implement Predictive Analytics - Lab - - - -In this lab, you will implement predictive analytics to predict the likelihood a taxi driver will be receive a tip given detail about the trip including the number of passengers, the trip distance (as measured by the odometer), the linear trip distance (e.g., as the crow flies), and the trip duration. Using SQL Server 2016 R Services, you will train the model, store the model in a table, and make the prediction available via a stored procedure which you will invoke from a simple node.js application. - -Requirements ------------------ -* [SQL Server 2016 Developer Edition](https://www.microsoft.com/en-us/sql-server/sql-server-editions-developers) or higher -* [Visual Studio Code](http://code.visualstudio.com) -* Node.js - -A tool to run SQL scripts against your SQL Server database, such as [SQL Server Management Studio (SSMS)](https://msdn.microsoft.com/library/mt238290.aspx) -This lab assumes you have setup SQL Server 2016 Developer Edition locally on your workstation or a remote instance. - -Required SQL Server Configuration -* Make sure that your installation of SQL Server includes R Services. -* Using SQL Server Configuration Manager, make sure that TCP/IP connections are enabled to your instance of SQL Server. -* Be sure that the SQL Server, SQL Server Launchpad and SQL Server Browser services are all running. - - - -Download the Project ----------------------- -Clone this repo to have the sample application and setup scripts. - -### Setup the sample database - -The following steps will get your taxidata database setup and loaded with data. - -1. Using the SQL tool of your choice (SQL Server Management Studio, Visual Studio Code with the MSSQL extension), connect to your database and execute the following scripts (provided with the project files) to create the database, a table to hold the taxi data, and load the 1.7M records into the taxi trip data table. - - *CreateDatabase.sql* - - *Create nyctaxi_features Table.sql* - - *Load nyctaxi_features using BCP.sql* **Important**, make sure that you edit the script to point to the folder where you've cloned the .bcp file -2. Next, create a table valued function that will package inputs received by the stored procedure into a tabular format by executing the following script. You will use this function later within the stored procedure that makes predictions. - - *Create Function fnEngineerFeatures.sql* -3. Execute the following script to create a table that will persist the predictive model you will generate. Observe that this table has a schema that consists of one column of type varbinary(max). This column will hold the serialized representation of your model. - - *Create nyc_taxi_models Table.sql* - -### Train the Model -To train your model, you will create a stored procedure that you can run at any time to train your model and store its serialized form in the nyctaxi_features table. - -1. Execute the following script to define the stored procedure: - - *Create Procedure TrainTipPredictionModel.sql* -2. Execute the following script to train the model and store it. - - *Exec TrainTipPredictionModel.sql*. You may need to [configure external scripts](https://msdn.microsoft.com/en-us/library/mt590884.aspx) and restart SQL. - -Let’s take a closer look at the contents of the stored procedure. - -``` -CREATE PROCEDURE [dbo].[TrainTipPredictionModel] -AS -BEGIN - DECLARE @inquery nvarchar(max) = N' - select tipped, passenger_count, trip_time_in_secs, trip_distance, direct_distance - from nyctaxi_features -' - -- Before insterting a new model, we delete the previous one - truncate table dbo.nyc_taxi_models - - -- Insert the trained model into a database table - INSERT INTO nyc_taxi_models - EXEC sp_execute_external_script - @language = N'R', - @script = N' - - ##Create model - logitObj <- rxLogit(tipped ~ passenger_count + trip_distance + trip_time_in_secs + - direct_distance, data = InputDataSet) - - ##Serialize model and put it in data frame - trained_model <- data.frame(model=as.raw(serialize(logitObj, NULL))); - ', - @input_data_1 = @inquery, - @output_data_1_name = N'trained_model' - ; - -END -GO -``` -The procedure begins by defining a query that retrieves the sample data contained in the nyctaxi_features table. -``` - DECLARE @inquery nvarchar(max) = N' - select tipped, passenger_count, trip_time_in_secs, trip_distance, direct_distance - from nyctaxi_features -' -``` -This query is passed as one of the parameters to sp_execute_external_script, via the @input_data_1 parameter. - -Next, a call to sp_execute_external_script is constructed. The return value of this stored procedure call is the serialized model, which is saved into the nyc_taxi_models table. The inputs to sp_execute_external_script are: -* __@language__: needs to indicate that the script is written in the R language. -* __@script__: this is the actual R script that uses the rxLogit function to train a model. -* __@input_data_1__: by convention represent the query that is accessible via InputDataSet within the R script. -* __@output_data_1_name__: provides the column name used in the result set containing the serialized model. - -Looking at the R script specifically, we have: - -``` -##Create model -logitObj <- rxLogit(tipped ~ passenger_count + trip_distance + trip_time_in_secs + - direct_distance, data = InputDataSet) -##Serialize model and put it in data frame -trained_model <- data.frame(model=as.raw(serialize(logitObj, NULL))); -``` - -The second line trains the model using the **rxLogit** method, which performs a **logistic regression**. Observe that the inputs are expressed in a formula syntax that describes what feature to predict and what features to use in its prediction: - -``` -tipped ~ passenger_count + trip_distance + trip_time_in_secs + direct_distance -``` - -The formula reads as such: predict **tipped** given the *passenger_count*, *trip_distance*, *trip_time_in_secs* and *direct_distance*. The source of these features comes from the data set made available via the InputDataSet variable. - -After that, we serialize the model into a **data.frame** and store it in the *trained_model* variable, which is returned as an output result set consisting of one cell with the column name *trained_model* and value of the serialized model. - -### Operationalize the Model -With trained model in hand, you are ready operationalize the model and make it available to your application. - -1. Execute the following script to operationalize the model in a stored procedure. - - *Create Procedure PredictTip.sql* - -Let’s take a closer look at this stored procedure. -``` -CREATE PROCEDURE [dbo].[PredictTip] - @passenger_count int = 0, - @trip_distance float = 0, - @trip_time_in_secs int = 0, - @direct_distance float = 0 -AS -BEGIN - - -- Package the inputs as a table - DECLARE @inquery nvarchar(max) = N' - SELECT * FROM [dbo].[fnEngineerFeatures]( - @passenger_count, - @trip_distance, - @trip_time_in_secs, - @direct_distance) - ' - - -- Load the serialized model from the nyc_taxi_models table - DECLARE @lmodel2 varbinary(max) = (SELECT TOP 1 model FROM nyc_taxi_models); - - -- Invoke the prediction - EXEC sp_execute_external_script - @language = N'R', - @script = N' - mod <- unserialize(as.raw(model)); - OutputDataSet<-rxPredict(modelObject = mod, data = InputDataSet, - outData = NULL, - predVarNames = "Score", type = "response", - writeModelVars = FALSE, overwrite = TRUE); - ', - @input_data_1 = @inquery, - @params = N'@model varbinary(max), - @passenger_count int, - @trip_distance float, - @trip_time_in_secs int , - @direct_distance float', - @model = @lmodel2, - @passenger_count = @passenger_count , - @trip_distance = @trip_distance, - @trip_time_in_secs = @trip_time_in_secs, - @direct_distance = @direct_distance - WITH RESULT SETS ((Score float)); - -END -``` -The PredictTip procedure takes as input the passenger count, trip distance (odometer reading), trip time and direct distance (calculated linear distance). - -The first query uses the fnEngineerFeatures table valued function to package the values of the input parameters as a table: -``` - DECLARE @inquery nvarchar(max) = N' - SELECT * FROM [dbo].[fnEngineerFeatures]( - @passenger_count, - @trip_distance, - @trip_time_in_secs, - @direct_distance) - ' -``` -After that we retrieve the serialized model from the nyc_taxi_models table: - -``` --- Load the serialized model from the nyc_taxi_models table - DECLARE @lmodel2 varbinary(max) = (SELECT TOP 1 model FROM nyc_taxi_models); -``` - -Following that we invoke the prediction using a call to sp_execute_external_script: - -``` - --Invoke the prediction - EXEC sp_execute_external_script - @language = N'R', - @script = N' - mod <- unserialize(as.raw(model)); - - OutputDataSet<-rxPredict(modelObject = mod, data = InputDataSet, - outData = NULL, - predVarNames = "Score", type = "response", - writeModelVars = FALSE, overwrite = TRUE); - ', - @input_data_1 = @inquery, - @params = N'@model varbinary(max), - @passenger_count int, - @trip_distance float, - @trip_time_in_secs int , - @direct_distance float', - @model = @lmodel2, - @passenger_count = @passenger_count , - @trip_distance = @trip_distance, - @trip_time_in_secs = @trip_time_in_secs, - @direct_distance = @direct_distance - WITH RESULT SETS ((Score float)); -``` - -Observe that we pass as input the following parameters: -* @language: needs to indicate that the script is written in the R language. -* @script: this is the actual R script that uses the rxPredict function to make the prediction. -* @input_data_1: the query which contains the one row of data against which we make a prediction. -* @params: defines the parameters and SQL types of all the parameters used. -* @model: the serialized model. -* @passenger_count, @trip_distance, @trip_time_in_secs, @direct_distance: the values that will be packaged into a table after executing the query defined by @inquery. - -The R script used for prediction has only the following two lines: -``` -mod <- unserialize(as.raw(model)); - -OutputDataSet<-rxPredict(modelObject = mod, data = InputDataSet, - outData = NULL, predVarNames = "Score", type = "response", - writeModelVars = FALSE, overwrite = TRUE); - -``` - -The first line deserializes the model so it is in a form useable by the **rxPredict** method. The second line invokes rxPredict which uses the model against the supplied row of data (within InputDataSet, which is sourced from the query in @inquery). - -Finally, the script ends using the following line: - -``` -WITH RESULT SETS ((Score float)); -``` - -This schematizes the result set returned in OutputDataSet within the R script. This data set has one column, labeled Score with a type of float. The label of “Score” was configured in the call to rxPredict via the predVarNames parameter. - -### Execute a prediction in T-SQL -Now you are ready to give your predictive stored procedure a test run. - -1. Run the following script to predict the probability of a tip using the PredictTip stored procedure. - - *Exec PredictTip.sql* -2. You should get a result set consisting of one row and one column (labeled Score), for example: - - - -### Execute the sample in Node.js -Now let’s integrate a call to this stored procedure from our node.js sample application. - -1. Within the root of the project directory, at the command line execute: - -``` -npm install tedious -``` - -2. This will install the tedious package which we use to connect to SQL Server. - -3. Open TipPredictor.js in Visual Studio Code. - -4. Near the top, modify the values of the config element so that they contain the appropriate values to connect to your instance of the taxidata database. - -Provide the connection details appropriate to your environment (Change the user/pass and instanceName to match your environment) - -``` -var config = { -userName: 'youruser', -password: 'yourpass', -server: 'localhost', -options: { -database: 'taxidata', -instanceName: 'SQL2016DEVED', -encrypt: true -} -}; -``` - -5. Save the file. -6. Scroll down to the connect.on() callback implementation. - -``` -connection.on('connect', function(err) { - - if (err) - { - console.log("Unable to Connect: " + err); - return; - } - - // If no error, then good to go... - console.log("Connected."); - - executeStatement(); - -}); -``` - -7. Observe that this method connects to SQL Server using tedious. If it connects successfully, it executes the method executeStatement(). -8. Look at the implementation for executeStatement(). - -``` -function executeStatement() { - // Specify the name of the predictive stored procedure - storedProcedureName = "[dbo].[PredictTip]"; - - request = new Request(storedProcedureName, function(err, rowCount) { - if (err) { - console.log(err); - } else { - console.log(rowCount + ' rows'); - } - }); - - // The input values to the prediction are provided here: - request.addParameter('passenger_count', TYPES.Int, '1'); - request.addParameter('trip_distance', TYPES.Float, '2.5'); - request.addParameter('trip_time_in_secs', TYPES.Int, '631'); - request.addParameter('direct_distance', TYPES.Float, '2'); - - // Iterate over any received rows in the result - request.on('row', function(columns) { - columns.forEach(function(column) { - console.log(column.metadata.colName + " = " + column.value); - }); - }); - - connection.callProcedure(request); -} -``` - -9. Observe that this method builds up a Request object that takes the stored procedure name and contains the input parameters upon which the prediction will execute. The return value of the stored procedure is handled via the *request.on(‘row’)* callback. The stored procedure is actually invoked at the last statement, via *connection.callProcedure(request)*. - -10. Open an instance of the command line and navigate to the directory containing TipPredictor.js. - -11. Run the sample application by typing: - -``` -node TipPredictor.js -``` - -12. You should see output like the following (which in this case means there is a 53% chance of a tip): - -``` -node TipPredictor.js -Connected. -Score = 0.5333974344542649 -3 rows -``` - -### Congratulations!!! -You’ve just trained and operationalized a model using SQL Server 2016 and enabled a node.js application with predictive analytics capabilities. - -### Additional resources +# Implement Predictive Analytics - Lab + + + +In this lab, you will implement predictive analytics to predict the likelihood a taxi driver will be receive a tip given detail about the trip including the number of passengers, the trip distance (as measured by the odometer), the linear trip distance (e.g., as the crow flies), and the trip duration. Using SQL Server 2016 R Services, you will train the model, store the model in a table, and make the prediction available via a stored procedure which you will invoke from a simple node.js application. + +Requirements +----------------- +* [SQL Server 2016 Developer Edition](https://www.microsoft.com/en-us/sql-server/sql-server-editions-developers) or higher +* [Visual Studio Code](http://code.visualstudio.com) +* Node.js + +A tool to run SQL scripts against your SQL Server database, such as [SQL Server Management Studio (SSMS)](https://msdn.microsoft.com/library/mt238290.aspx) +This lab assumes you have setup SQL Server 2016 Developer Edition locally on your workstation or a remote instance. + +Required SQL Server Configuration +* Make sure that your installation of SQL Server includes R Services. +* Using SQL Server Configuration Manager, make sure that TCP/IP connections are enabled to your instance of SQL Server. +* Be sure that the SQL Server, SQL Server Launchpad and SQL Server Browser services are all running. + + + +Download the Project +---------------------- +Clone this repo to have the sample application and setup scripts. + +### Setup the sample database + +The following steps will get your taxidata database setup and loaded with data. + +1. Using the SQL tool of your choice (SQL Server Management Studio, Visual Studio Code with the MSSQL extension), connect to your database and execute the following scripts (provided with the project files) to create the database, a table to hold the taxi data, and load the 1.7M records into the taxi trip data table. + - *CreateDatabase.sql* + - *Create nyctaxi_features Table.sql* + - *Load nyctaxi_features using BCP.sql* **Important**, make sure that you edit the script to point to the folder where you've cloned the .bcp file +2. Next, create a table valued function that will package inputs received by the stored procedure into a tabular format by executing the following script. You will use this function later within the stored procedure that makes predictions. + - *Create Function fnEngineerFeatures.sql* +3. Execute the following script to create a table that will persist the predictive model you will generate. Observe that this table has a schema that consists of one column of type varbinary(max). This column will hold the serialized representation of your model. + - *Create nyc_taxi_models Table.sql* + +### Train the Model +To train your model, you will create a stored procedure that you can run at any time to train your model and store its serialized form in the nyctaxi_features table. + +1. Execute the following script to define the stored procedure: + - *Create Procedure TrainTipPredictionModel.sql* +2. Execute the following script to train the model and store it. + - *Exec TrainTipPredictionModel.sql*. You may need to [configure external scripts](https://msdn.microsoft.com/en-us/library/mt590884.aspx) and restart SQL. + +Let’s take a closer look at the contents of the stored procedure. + +``` +CREATE PROCEDURE [dbo].[TrainTipPredictionModel] +AS +BEGIN + DECLARE @inquery nvarchar(max) = N' + select tipped, passenger_count, trip_time_in_secs, trip_distance, direct_distance + from nyctaxi_features +' + -- Before insterting a new model, we delete the previous one + truncate table dbo.nyc_taxi_models + + -- Insert the trained model into a database table + INSERT INTO nyc_taxi_models + EXEC sp_execute_external_script + @language = N'R', + @script = N' + + ##Create model + logitObj <- rxLogit(tipped ~ passenger_count + trip_distance + trip_time_in_secs + + direct_distance, data = InputDataSet) + + ##Serialize model and put it in data frame + trained_model <- data.frame(model=as.raw(serialize(logitObj, NULL))); + ', + @input_data_1 = @inquery, + @output_data_1_name = N'trained_model' + ; + +END +GO +``` +The procedure begins by defining a query that retrieves the sample data contained in the nyctaxi_features table. +``` + DECLARE @inquery nvarchar(max) = N' + select tipped, passenger_count, trip_time_in_secs, trip_distance, direct_distance + from nyctaxi_features +' +``` +This query is passed as one of the parameters to sp_execute_external_script, via the @input_data_1 parameter. + +Next, a call to sp_execute_external_script is constructed. The return value of this stored procedure call is the serialized model, which is saved into the nyc_taxi_models table. The inputs to sp_execute_external_script are: +* __@language__: needs to indicate that the script is written in the R language. +* __@script__: this is the actual R script that uses the rxLogit function to train a model. +* __@input_data_1__: by convention represent the query that is accessible via InputDataSet within the R script. +* __@output_data_1_name__: provides the column name used in the result set containing the serialized model. + +Looking at the R script specifically, we have: + +``` +##Create model +logitObj <- rxLogit(tipped ~ passenger_count + trip_distance + trip_time_in_secs + + direct_distance, data = InputDataSet) +##Serialize model and put it in data frame +trained_model <- data.frame(model=as.raw(serialize(logitObj, NULL))); +``` + +The second line trains the model using the **rxLogit** method, which performs a **logistic regression**. Observe that the inputs are expressed in a formula syntax that describes what feature to predict and what features to use in its prediction: + +``` +tipped ~ passenger_count + trip_distance + trip_time_in_secs + direct_distance +``` + +The formula reads as such: predict **tipped** given the *passenger_count*, *trip_distance*, *trip_time_in_secs* and *direct_distance*. The source of these features comes from the data set made available via the InputDataSet variable. + +After that, we serialize the model into a **data.frame** and store it in the *trained_model* variable, which is returned as an output result set consisting of one cell with the column name *trained_model* and value of the serialized model. + +### Operationalize the Model +With trained model in hand, you are ready operationalize the model and make it available to your application. + +1. Execute the following script to operationalize the model in a stored procedure. + - *Create Procedure PredictTip.sql* + +Let’s take a closer look at this stored procedure. +``` +CREATE PROCEDURE [dbo].[PredictTip] + @passenger_count int = 0, + @trip_distance float = 0, + @trip_time_in_secs int = 0, + @direct_distance float = 0 +AS +BEGIN + + -- Package the inputs as a table + DECLARE @inquery nvarchar(max) = N' + SELECT * FROM [dbo].[fnEngineerFeatures]( + @passenger_count, + @trip_distance, + @trip_time_in_secs, + @direct_distance) + ' + + -- Load the serialized model from the nyc_taxi_models table + DECLARE @lmodel2 varbinary(max) = (SELECT TOP 1 model FROM nyc_taxi_models); + + -- Invoke the prediction + EXEC sp_execute_external_script + @language = N'R', + @script = N' + mod <- unserialize(as.raw(model)); + OutputDataSet<-rxPredict(modelObject = mod, data = InputDataSet, + outData = NULL, + predVarNames = "Score", type = "response", + writeModelVars = FALSE, overwrite = TRUE); + ', + @input_data_1 = @inquery, + @params = N'@model varbinary(max), + @passenger_count int, + @trip_distance float, + @trip_time_in_secs int , + @direct_distance float', + @model = @lmodel2, + @passenger_count = @passenger_count , + @trip_distance = @trip_distance, + @trip_time_in_secs = @trip_time_in_secs, + @direct_distance = @direct_distance + WITH RESULT SETS ((Score float)); + +END +``` +The PredictTip procedure takes as input the passenger count, trip distance (odometer reading), trip time and direct distance (calculated linear distance). + +The first query uses the fnEngineerFeatures table valued function to package the values of the input parameters as a table: +``` + DECLARE @inquery nvarchar(max) = N' + SELECT * FROM [dbo].[fnEngineerFeatures]( + @passenger_count, + @trip_distance, + @trip_time_in_secs, + @direct_distance) + ' +``` +After that we retrieve the serialized model from the nyc_taxi_models table: + +``` +-- Load the serialized model from the nyc_taxi_models table + DECLARE @lmodel2 varbinary(max) = (SELECT TOP 1 model FROM nyc_taxi_models); +``` + +Following that we invoke the prediction using a call to sp_execute_external_script: + +``` + --Invoke the prediction + EXEC sp_execute_external_script + @language = N'R', + @script = N' + mod <- unserialize(as.raw(model)); + + OutputDataSet<-rxPredict(modelObject = mod, data = InputDataSet, + outData = NULL, + predVarNames = "Score", type = "response", + writeModelVars = FALSE, overwrite = TRUE); + ', + @input_data_1 = @inquery, + @params = N'@model varbinary(max), + @passenger_count int, + @trip_distance float, + @trip_time_in_secs int , + @direct_distance float', + @model = @lmodel2, + @passenger_count = @passenger_count , + @trip_distance = @trip_distance, + @trip_time_in_secs = @trip_time_in_secs, + @direct_distance = @direct_distance + WITH RESULT SETS ((Score float)); +``` + +Observe that we pass as input the following parameters: +* @language: needs to indicate that the script is written in the R language. +* @script: this is the actual R script that uses the rxPredict function to make the prediction. +* @input_data_1: the query which contains the one row of data against which we make a prediction. +* @params: defines the parameters and SQL types of all the parameters used. +* @model: the serialized model. +* @passenger_count, @trip_distance, @trip_time_in_secs, @direct_distance: the values that will be packaged into a table after executing the query defined by @inquery. + +The R script used for prediction has only the following two lines: +``` +mod <- unserialize(as.raw(model)); + +OutputDataSet<-rxPredict(modelObject = mod, data = InputDataSet, + outData = NULL, predVarNames = "Score", type = "response", + writeModelVars = FALSE, overwrite = TRUE); + +``` + +The first line deserializes the model so it is in a form useable by the **rxPredict** method. The second line invokes rxPredict which uses the model against the supplied row of data (within InputDataSet, which is sourced from the query in @inquery). + +Finally, the script ends using the following line: + +``` +WITH RESULT SETS ((Score float)); +``` + +This schematizes the result set returned in OutputDataSet within the R script. This data set has one column, labeled Score with a type of float. The label of “Score” was configured in the call to rxPredict via the predVarNames parameter. + +### Execute a prediction in T-SQL +Now you are ready to give your predictive stored procedure a test run. + +1. Run the following script to predict the probability of a tip using the PredictTip stored procedure. + - *Exec PredictTip.sql* +2. You should get a result set consisting of one row and one column (labeled Score), for example: + + + +### Execute the sample in Node.js +Now let’s integrate a call to this stored procedure from our node.js sample application. + +1. Within the root of the project directory, at the command line execute: + +``` +npm install tedious +``` + +2. This will install the tedious package which we use to connect to SQL Server. + +3. Open TipPredictor.js in Visual Studio Code. + +4. Near the top, modify the values of the config element so that they contain the appropriate values to connect to your instance of the taxidata database. + +Provide the connection details appropriate to your environment (Change the user/pass and instanceName to match your environment) + +``` +var config = { +userName: 'youruser', +password: 'yourpass', +server: 'localhost', +options: { +database: 'taxidata', +instanceName: 'SQL2016DEVED', +encrypt: true +} +}; +``` + +5. Save the file. +6. Scroll down to the connect.on() callback implementation. + +``` +connection.on('connect', function(err) { + + if (err) + { + console.log("Unable to Connect: " + err); + return; + } + + // If no error, then good to go... + console.log("Connected."); + + executeStatement(); + +}); +``` + +7. Observe that this method connects to SQL Server using tedious. If it connects successfully, it executes the method executeStatement(). +8. Look at the implementation for executeStatement(). + +``` +function executeStatement() { + // Specify the name of the predictive stored procedure + storedProcedureName = "[dbo].[PredictTip]"; + + request = new Request(storedProcedureName, function(err, rowCount) { + if (err) { + console.log(err); + } else { + console.log(rowCount + ' rows'); + } + }); + + // The input values to the prediction are provided here: + request.addParameter('passenger_count', TYPES.Int, '1'); + request.addParameter('trip_distance', TYPES.Float, '2.5'); + request.addParameter('trip_time_in_secs', TYPES.Int, '631'); + request.addParameter('direct_distance', TYPES.Float, '2'); + + // Iterate over any received rows in the result + request.on('row', function(columns) { + columns.forEach(function(column) { + console.log(column.metadata.colName + " = " + column.value); + }); + }); + + connection.callProcedure(request); +} +``` + +9. Observe that this method builds up a Request object that takes the stored procedure name and contains the input parameters upon which the prediction will execute. The return value of the stored procedure is handled via the *request.on(‘row’)* callback. The stored procedure is actually invoked at the last statement, via *connection.callProcedure(request)*. + +10. Open an instance of the command line and navigate to the directory containing TipPredictor.js. + +11. Run the sample application by typing: + +``` +node TipPredictor.js +``` + +12. You should see output like the following (which in this case means there is a 53% chance of a tip): + +``` +node TipPredictor.js +Connected. +Score = 0.5333974344542649 +3 rows +``` + +### Congratulations!!! +You’ve just trained and operationalized a model using SQL Server 2016 and enabled a node.js application with predictive analytics capabilities. + +### Additional resources diff --git a/samples/features/r-services/Implementing Predictive Analytics/scripts/Load nyctaxi_features using BCP.sql b/samples/features/r-services/predictive-analytics/scripts/Load nyctaxi_features using BCP.sql similarity index 95% rename from samples/features/r-services/Implementing Predictive Analytics/scripts/Load nyctaxi_features using BCP.sql rename to samples/features/r-services/predictive-analytics/scripts/Load nyctaxi_features using BCP.sql index 0f55df2a..fd4c6b52 100644 --- a/samples/features/r-services/Implementing Predictive Analytics/scripts/Load nyctaxi_features using BCP.sql +++ b/samples/features/r-services/predictive-analytics/scripts/Load nyctaxi_features using BCP.sql @@ -1,10 +1,10 @@ -USE taxidata; -GO - - -BULK INSERT taxidata.dbo.nyctaxi_features - FROM 'C:\Implementing Predictive Analytics\nyctaxi_features.bcp' - WITH ( - DATAFILETYPE = 'native' - ); +USE taxidata; +GO + + +BULK INSERT taxidata.dbo.nyctaxi_features + FROM 'C:\Implementing Predictive Analytics\nyctaxi_features.bcp' + WITH ( + DATAFILETYPE = 'native' + ); GO \ No newline at end of file diff --git a/samples/features/r-services/Implementing Predictive Analytics/scripts/TipPredictor.js b/samples/features/r-services/predictive-analytics/scripts/TipPredictor.js similarity index 96% rename from samples/features/r-services/Implementing Predictive Analytics/scripts/TipPredictor.js rename to samples/features/r-services/predictive-analytics/scripts/TipPredictor.js index 4955f9d9..7cec4189 100644 --- a/samples/features/r-services/Implementing Predictive Analytics/scripts/TipPredictor.js +++ b/samples/features/r-services/predictive-analytics/scripts/TipPredictor.js @@ -1,60 +1,60 @@ -var Connection = require('tedious').Connection; -var Request = require('tedious').Request; -var TYPES = require('tedious').TYPES; - -// Provide the connection details appropriate to your environment -var config = { - userName: '', - password: '', - server: '', - options: { - database: 'taxidata', - encrypt: true - } -}; - -var connection = new Connection(config); - -connection.on('connect', function(err) { - - if (err) - { - console.log("Unable to Connect: " + err); - return; - } - - // If no error, then good to go... - console.log("Connected."); - - executeStatement(); - -}); - - -function executeStatement() { - // Specify the name of the predictive stored procedure - storedProcedureName = "[dbo].[PredictTip]"; - - request = new Request(storedProcedureName, function(err, rowCount) { - if (err) { - console.log(err); - } else { - console.log(rowCount + ' rows'); - } - }); - - // The input values to the prediction are provided here: - request.addParameter('passenger_count', TYPES.Int, '1'); - request.addParameter('trip_distance', TYPES.Float, '2.5'); - request.addParameter('trip_time_in_secs', TYPES.Int, '631'); - request.addParameter('direct_distance', TYPES.Float, '2'); - - // Iterate over any received rows in the result - request.on('row', function(columns) { - columns.forEach(function(column) { - console.log(column.metadata.colName + " = " + column.value); - }); - }); - - connection.callProcedure(request); +var Connection = require('tedious').Connection; +var Request = require('tedious').Request; +var TYPES = require('tedious').TYPES; + +// Provide the connection details appropriate to your environment +var config = { + userName: '', + password: '', + server: '', + options: { + database: 'taxidata', + encrypt: true + } +}; + +var connection = new Connection(config); + +connection.on('connect', function(err) { + + if (err) + { + console.log("Unable to Connect: " + err); + return; + } + + // If no error, then good to go... + console.log("Connected."); + + executeStatement(); + +}); + + +function executeStatement() { + // Specify the name of the predictive stored procedure + storedProcedureName = "[dbo].[PredictTip]"; + + request = new Request(storedProcedureName, function(err, rowCount) { + if (err) { + console.log(err); + } else { + console.log(rowCount + ' rows'); + } + }); + + // The input values to the prediction are provided here: + request.addParameter('passenger_count', TYPES.Int, '1'); + request.addParameter('trip_distance', TYPES.Float, '2.5'); + request.addParameter('trip_time_in_secs', TYPES.Int, '631'); + request.addParameter('direct_distance', TYPES.Float, '2'); + + // Iterate over any received rows in the result + request.on('row', function(columns) { + columns.forEach(function(column) { + console.log(column.metadata.colName + " = " + column.value); + }); + }); + + connection.callProcedure(request); } \ No newline at end of file diff --git a/samples/features/r-services/SSMS-Custom-Reports/R Services - Active Sessions.rdl b/samples/features/r-services/ssms-reports/R Services - Active Sessions.rdl similarity index 100% rename from samples/features/r-services/SSMS-Custom-Reports/R Services - Active Sessions.rdl rename to samples/features/r-services/ssms-reports/R Services - Active Sessions.rdl diff --git a/samples/features/r-services/SSMS-Custom-Reports/R Services - Configuration.rdl b/samples/features/r-services/ssms-reports/R Services - Configuration.rdl similarity index 100% rename from samples/features/r-services/SSMS-Custom-Reports/R Services - Configuration.rdl rename to samples/features/r-services/ssms-reports/R Services - Configuration.rdl diff --git a/samples/features/r-services/SSMS-Custom-Reports/R Services - Configure Instance.rdl b/samples/features/r-services/ssms-reports/R Services - Configure Instance.rdl similarity index 100% rename from samples/features/r-services/SSMS-Custom-Reports/R Services - Configure Instance.rdl rename to samples/features/r-services/ssms-reports/R Services - Configure Instance.rdl diff --git a/samples/features/r-services/SSMS-Custom-Reports/R Services - Execution Statistics.rdl b/samples/features/r-services/ssms-reports/R Services - Execution Statistics.rdl similarity index 100% rename from samples/features/r-services/SSMS-Custom-Reports/R Services - Execution Statistics.rdl rename to samples/features/r-services/ssms-reports/R Services - Execution Statistics.rdl diff --git a/samples/features/r-services/SSMS-Custom-Reports/R Services - Extended Events.rdl b/samples/features/r-services/ssms-reports/R Services - Extended Events.rdl similarity index 100% rename from samples/features/r-services/SSMS-Custom-Reports/R Services - Extended Events.rdl rename to samples/features/r-services/ssms-reports/R Services - Extended Events.rdl diff --git a/samples/features/r-services/SSMS-Custom-Reports/R Services - Packages.rdl b/samples/features/r-services/ssms-reports/R Services - Packages.rdl similarity index 100% rename from samples/features/r-services/SSMS-Custom-Reports/R Services - Packages.rdl rename to samples/features/r-services/ssms-reports/R Services - Packages.rdl diff --git a/samples/features/r-services/SSMS-Custom-Reports/R Services - Resource Usage.rdl b/samples/features/r-services/ssms-reports/R Services - Resource Usage.rdl similarity index 100% rename from samples/features/r-services/SSMS-Custom-Reports/R Services - Resource Usage.rdl rename to samples/features/r-services/ssms-reports/R Services - Resource Usage.rdl diff --git a/samples/features/r-services/SSMS-Custom-Reports/R Services - Script.rdl b/samples/features/r-services/ssms-reports/R Services - Script.rdl similarity index 100% rename from samples/features/r-services/SSMS-Custom-Reports/R Services - Script.rdl rename to samples/features/r-services/ssms-reports/R Services - Script.rdl diff --git a/samples/features/r-services/SSMS-Custom-Reports/README.md b/samples/features/r-services/ssms-reports/README.md similarity index 100% rename from samples/features/r-services/SSMS-Custom-Reports/README.md rename to samples/features/r-services/ssms-reports/README.md diff --git a/samples/features/r-services/Telco Customer Churn v1/Data/edw_cdr.csv b/samples/features/r-services/telco-customer-churn-v1/Data/edw_cdr.csv similarity index 100% rename from samples/features/r-services/Telco Customer Churn v1/Data/edw_cdr.csv rename to samples/features/r-services/telco-customer-churn-v1/Data/edw_cdr.csv diff --git a/samples/features/r-services/Telco Customer Churn v1/Data/state_latlon.csv b/samples/features/r-services/telco-customer-churn-v1/Data/state_latlon.csv similarity index 100% rename from samples/features/r-services/Telco Customer Churn v1/Data/state_latlon.csv rename to samples/features/r-services/telco-customer-churn-v1/Data/state_latlon.csv diff --git a/samples/features/r-services/Telco Customer Churn v1/Image/reportBuilder1.png b/samples/features/r-services/telco-customer-churn-v1/Image/reportBuilder1.png similarity index 100% rename from samples/features/r-services/Telco Customer Churn v1/Image/reportBuilder1.png rename to samples/features/r-services/telco-customer-churn-v1/Image/reportBuilder1.png diff --git a/samples/features/r-services/Telco Customer Churn v1/Image/reportBuilder2.png b/samples/features/r-services/telco-customer-churn-v1/Image/reportBuilder2.png similarity index 100% rename from samples/features/r-services/Telco Customer Churn v1/Image/reportBuilder2.png rename to samples/features/r-services/telco-customer-churn-v1/Image/reportBuilder2.png diff --git a/samples/features/r-services/Telco Customer Churn v1/Image/reportBuilder3.png b/samples/features/r-services/telco-customer-churn-v1/Image/reportBuilder3.png similarity index 100% rename from samples/features/r-services/Telco Customer Churn v1/Image/reportBuilder3.png rename to samples/features/r-services/telco-customer-churn-v1/Image/reportBuilder3.png diff --git a/samples/features/r-services/Telco Customer Churn v1/Image/shinyLeaflet.png b/samples/features/r-services/telco-customer-churn-v1/Image/shinyLeaflet.png similarity index 100% rename from samples/features/r-services/Telco Customer Churn v1/Image/shinyLeaflet.png rename to samples/features/r-services/telco-customer-churn-v1/Image/shinyLeaflet.png diff --git a/samples/features/r-services/Telco Customer Churn v1/Image/sqlQueryrxforest.png b/samples/features/r-services/telco-customer-churn-v1/Image/sqlQueryrxforest.png similarity index 100% rename from samples/features/r-services/Telco Customer Churn v1/Image/sqlQueryrxforest.png rename to samples/features/r-services/telco-customer-churn-v1/Image/sqlQueryrxforest.png diff --git a/samples/features/r-services/Telco Customer Churn v1/R/README.md b/samples/features/r-services/telco-customer-churn-v1/R/README.md similarity index 100% rename from samples/features/r-services/Telco Customer Churn v1/R/README.md rename to samples/features/r-services/telco-customer-churn-v1/R/README.md diff --git a/samples/features/r-services/Telco Customer Churn v1/R/telcoChurn-dataExploration.R b/samples/features/r-services/telco-customer-churn-v1/R/telcoChurn-dataExploration.R similarity index 100% rename from samples/features/r-services/Telco Customer Churn v1/R/telcoChurn-dataExploration.R rename to samples/features/r-services/telco-customer-churn-v1/R/telcoChurn-dataExploration.R diff --git a/samples/features/r-services/Telco Customer Churn v1/R/telcoChurn-dataPreparation.R b/samples/features/r-services/telco-customer-churn-v1/R/telcoChurn-dataPreparation.R similarity index 100% rename from samples/features/r-services/Telco Customer Churn v1/R/telcoChurn-dataPreparation.R rename to samples/features/r-services/telco-customer-churn-v1/R/telcoChurn-dataPreparation.R diff --git a/samples/features/r-services/Telco Customer Churn v1/R/telcoChurn-evaluate.R b/samples/features/r-services/telco-customer-churn-v1/R/telcoChurn-evaluate.R similarity index 100% rename from samples/features/r-services/Telco Customer Churn v1/R/telcoChurn-evaluate.R rename to samples/features/r-services/telco-customer-churn-v1/R/telcoChurn-evaluate.R diff --git a/samples/features/r-services/Telco Customer Churn v1/R/telcoChurn-main.R b/samples/features/r-services/telco-customer-churn-v1/R/telcoChurn-main.R similarity index 100% rename from samples/features/r-services/Telco Customer Churn v1/R/telcoChurn-main.R rename to samples/features/r-services/telco-customer-churn-v1/R/telcoChurn-main.R diff --git a/samples/features/r-services/Telco Customer Churn v1/R/telcoChurn-modelComparison.R b/samples/features/r-services/telco-customer-churn-v1/R/telcoChurn-modelComparison.R similarity index 100% rename from samples/features/r-services/Telco Customer Churn v1/R/telcoChurn-modelComparison.R rename to samples/features/r-services/telco-customer-churn-v1/R/telcoChurn-modelComparison.R diff --git a/samples/features/r-services/Telco Customer Churn v1/R/telcoChurn-setUp.R b/samples/features/r-services/telco-customer-churn-v1/R/telcoChurn-setUp.R similarity index 100% rename from samples/features/r-services/Telco Customer Churn v1/R/telcoChurn-setUp.R rename to samples/features/r-services/telco-customer-churn-v1/R/telcoChurn-setUp.R diff --git a/samples/features/r-services/Telco Customer Churn v1/R/telcoChurn-trainModel.R b/samples/features/r-services/telco-customer-churn-v1/R/telcoChurn-trainModel.R similarity index 100% rename from samples/features/r-services/Telco Customer Churn v1/R/telcoChurn-trainModel.R rename to samples/features/r-services/telco-customer-churn-v1/R/telcoChurn-trainModel.R diff --git a/samples/features/r-services/Telco Customer Churn v1/README.md b/samples/features/r-services/telco-customer-churn-v1/README.md similarity index 100% rename from samples/features/r-services/Telco Customer Churn v1/README.md rename to samples/features/r-services/telco-customer-churn-v1/README.md diff --git a/samples/features/r-services/Telco Customer Churn v1/ReportBuilder/README.md b/samples/features/r-services/telco-customer-churn-v1/ReportBuilder/README.md similarity index 100% rename from samples/features/r-services/Telco Customer Churn v1/ReportBuilder/README.md rename to samples/features/r-services/telco-customer-churn-v1/ReportBuilder/README.md diff --git a/samples/features/r-services/Telco Customer Churn v1/ReportBuilder/telcoChurn-reportBuilder.rdl b/samples/features/r-services/telco-customer-churn-v1/ReportBuilder/telcoChurn-reportBuilder.rdl similarity index 100% rename from samples/features/r-services/Telco Customer Churn v1/ReportBuilder/telcoChurn-reportBuilder.rdl rename to samples/features/r-services/telco-customer-churn-v1/ReportBuilder/telcoChurn-reportBuilder.rdl diff --git a/samples/features/r-services/Telco Customer Churn v1/SQL/README.md b/samples/features/r-services/telco-customer-churn-v1/SQL/README.md similarity index 100% rename from samples/features/r-services/Telco Customer Churn v1/SQL/README.md rename to samples/features/r-services/telco-customer-churn-v1/SQL/README.md diff --git a/samples/features/r-services/Telco Customer Churn v1/SQL/telcoChurn-main.sql b/samples/features/r-services/telco-customer-churn-v1/SQL/telcoChurn-main.sql similarity index 100% rename from samples/features/r-services/Telco Customer Churn v1/SQL/telcoChurn-main.sql rename to samples/features/r-services/telco-customer-churn-v1/SQL/telcoChurn-main.sql diff --git a/samples/features/r-services/Telco Customer Churn v1/SQL/telcoChurn-operationalize.sql b/samples/features/r-services/telco-customer-churn-v1/SQL/telcoChurn-operationalize.sql similarity index 100% rename from samples/features/r-services/Telco Customer Churn v1/SQL/telcoChurn-operationalize.sql rename to samples/features/r-services/telco-customer-churn-v1/SQL/telcoChurn-operationalize.sql diff --git a/samples/features/r-services/Telco Customer Churn/R/README.md b/samples/features/r-services/telco-customer-churn/R/README.md similarity index 100% rename from samples/features/r-services/Telco Customer Churn/R/README.md rename to samples/features/r-services/telco-customer-churn/R/README.md diff --git a/samples/features/r-services/Telco Customer Churn/R/TelcoChurn-DataExploration.r b/samples/features/r-services/telco-customer-churn/R/TelcoChurn-DataExploration.r similarity index 100% rename from samples/features/r-services/Telco Customer Churn/R/TelcoChurn-DataExploration.r rename to samples/features/r-services/telco-customer-churn/R/TelcoChurn-DataExploration.r diff --git a/samples/features/r-services/Telco Customer Churn/R/TelcoChurn-DataPreparation.r b/samples/features/r-services/telco-customer-churn/R/TelcoChurn-DataPreparation.r similarity index 100% rename from samples/features/r-services/Telco Customer Churn/R/TelcoChurn-DataPreparation.r rename to samples/features/r-services/telco-customer-churn/R/TelcoChurn-DataPreparation.r diff --git a/samples/features/r-services/Telco Customer Churn/R/TelcoChurn-Main.r b/samples/features/r-services/telco-customer-churn/R/TelcoChurn-Main.r similarity index 100% rename from samples/features/r-services/Telco Customer Churn/R/TelcoChurn-Main.r rename to samples/features/r-services/telco-customer-churn/R/TelcoChurn-Main.r diff --git a/samples/features/r-services/Telco Customer Churn/R/TelcoChurn-ModelBuilding.r b/samples/features/r-services/telco-customer-churn/R/TelcoChurn-ModelBuilding.r similarity index 100% rename from samples/features/r-services/Telco Customer Churn/R/TelcoChurn-ModelBuilding.r rename to samples/features/r-services/telco-customer-churn/R/TelcoChurn-ModelBuilding.r diff --git a/samples/features/r-services/Telco Customer Churn/R/TelcoChurn-Setup.r b/samples/features/r-services/telco-customer-churn/R/TelcoChurn-Setup.r similarity index 100% rename from samples/features/r-services/Telco Customer Churn/R/TelcoChurn-Setup.r rename to samples/features/r-services/telco-customer-churn/R/TelcoChurn-Setup.r diff --git a/samples/features/r-services/Telco Customer Churn/README.md b/samples/features/r-services/telco-customer-churn/README.md similarity index 100% rename from samples/features/r-services/Telco Customer Churn/README.md rename to samples/features/r-services/telco-customer-churn/README.md diff --git a/samples/features/r-services/Telco Customer Churn/SQL Server/Enabling R scripts to run and Installing required R Packages.sql b/samples/features/r-services/telco-customer-churn/SQL Server/Enabling R scripts to run and Installing required R Packages.sql similarity index 100% rename from samples/features/r-services/Telco Customer Churn/SQL Server/Enabling R scripts to run and Installing required R Packages.sql rename to samples/features/r-services/telco-customer-churn/SQL Server/Enabling R scripts to run and Installing required R Packages.sql diff --git a/samples/features/r-services/Telco Customer Churn/SQL Server/README.md b/samples/features/r-services/telco-customer-churn/SQL Server/README.md similarity index 100% rename from samples/features/r-services/Telco Customer Churn/SQL Server/README.md rename to samples/features/r-services/telco-customer-churn/SQL Server/README.md diff --git a/samples/features/r-services/Telco Customer Churn/SQL Server/TelcoChurn-Main.sql b/samples/features/r-services/telco-customer-churn/SQL Server/TelcoChurn-Main.sql similarity index 100% rename from samples/features/r-services/Telco Customer Churn/SQL Server/TelcoChurn-Main.sql rename to samples/features/r-services/telco-customer-churn/SQL Server/TelcoChurn-Main.sql diff --git a/samples/features/r-services/Telco Customer Churn/SQL Server/TelcoChurn-Operationalize.sql b/samples/features/r-services/telco-customer-churn/SQL Server/TelcoChurn-Operationalize.sql similarity index 100% rename from samples/features/r-services/Telco Customer Churn/SQL Server/TelcoChurn-Operationalize.sql rename to samples/features/r-services/telco-customer-churn/SQL Server/TelcoChurn-Operationalize.sql diff --git a/samples/features/r-services/Telco Customer Churn/SQL Server/teloedw2.bak b/samples/features/r-services/telco-customer-churn/SQL Server/teloedw2.bak similarity index 100% rename from samples/features/r-services/Telco Customer Churn/SQL Server/teloedw2.bak rename to samples/features/r-services/telco-customer-churn/SQL Server/teloedw2.bak diff --git a/samples/tutorials/php/README.md b/samples/tutorials/php/README.md new file mode 100644 index 00000000..b46f012a --- /dev/null +++ b/samples/tutorials/php/README.md @@ -0,0 +1,8 @@ +# Developing applications with php and SQL Server + +Pick a platform below to get started: +* [RHEL](https://github.com/Microsoft/sql-server-samples/tree/master/samples/tutorials/php/RHEL) +* [Ubuntu](https://github.com/Microsoft/sql-server-samples/tree/master/samples/tutorials/php/Ubuntu) +* [Windows](https://github.com/Microsoft/sql-server-samples/tree/master/samples/tutorials/php/Windows) + +Please visit our [getting started tutorials](https://www.microsoft.com/en-us/sql-server/developer-get-started/)