2019年7月28日 星期日

SQL Server 2017 Machine Learning


1.啟動 SQL Server Launchpad service


2.檢查並啟用 external scripts enabled
    預設 SQL Server的external scripts enabled是停用的





執行以下語法啟用 external scripts enabled
EXEC sp_configure  'external scripts enabled', 1
RECONFIGURE WITH OVERRIDE 
 
    如果檢查run_value不是1,則需要重新啟動SQL Server讓設定生效


若正常啟用,run_value是1

3.請確認有 Python
   執行Python Script檢查Python版本

    若出現錯誤Msg 39011,可能是SQL Server Launchpad service服務沒有啟動,
 
   或是需要重新啟動一次

     若出現錯誤,可能是找不到Python
    Msg 39021, Level 16, State 1, Line 0
    Unable to launch runtime for 'Python' script. Please check the configuration of the 'Python' runtime.
    Msg 39019, Level 16, State 2, Line 0
    An external script error occurred:
    Unable to launch the runtime. ErrorCode 0x80070490: 1168(元素找不到。).

    或是SQL Server沒有安裝Machine Learning Services(In-Database)>Python

4.Run a Hello World script
    執行用Python Script Hello World

    若用R語言Hello World

5.確認revoscalepy可供使用
下列指令碼會示範如何擷取包含在 revoscalepy 內建的範例.xdf 資料檔案。


6.查看預先安裝的Python 套件清單
Microsoft 預先安裝在SQL Server執行個體的機器學習服務 Python 套件




Revoscalepy
維基百科
revoscalepy是由Microsoft創建的Python中的機器學習包。它作為Microsoft SQL Server 2017和Machine Learning Server 9.2.0及更高版本中的機器學習服務的一部分提供。[1]
該軟件包包含用於創建線性模型,邏輯回歸,隨機森林,決策樹和提升決策樹的功能,以及用於檢查數據的一些摘要功能。[2] 其他機器學習算法,如神經網絡,是在microsoftm中提供的,這是一個單獨的軟件包,它是MicrosoftML的Python版本。[3]
revoscalepy還包含用於在不同計算環境中運行機器學習算法的函數,包括SQL Server,Apache Spark和Hadoop。[2]

Next Step:
Quickstart: Create, train, and use a Python model with stored procedures in SQL Server
https://docs.microsoft.com/en-us/sql/advanced-analytics/tutorials/quickstart-python-train-score-in-tsql?view=sql-server-2017

Use Python with revoscalepy to create a model that runs remotely on SQL Server
https://docs.microsoft.com/en-us/sql/advanced-analytics/tutorials/use-python-revoscalepy-to-create-model?view=sql-server-2017


Reference:
SQL Server Machine Learning tutorials in R and Python
https://docs.microsoft.com/en-us/sql/advanced-analytics/tutorials/machine-learning-services-tutorials?view=sql-server-2017

Quickstart: Verify Python exists in SQL Server
https://docs.microsoft.com/en-us/sql/advanced-analytics/tutorials/quickstart-python-verify?view=sql-server-2017

revoscalepy (Python module in SQL Server)
https://docs.microsoft.com/zh-tw/sql/advanced-analytics/python/ref-py-revoscalepy?view=sql-server-2017

沒有留言:

Azure API Management

Azure API Management