iT邦幫忙

2019 iT 邦幫忙鐵人賽

DAY 27
0
Everything on Azure

Azure Machine Learning Studio系列 第 27

Azure Machine Learning Studio 使用 SQL 語法 Apply SQL Transformation

在 Azure Machine Learning Studio 中,可以使用 Apply SQL Transformation 針對輸入的資料集執行 SQL 語法,進行資料欄位的運算或彙總及條件篩選等,也可以將多個資料集資料合併起來

Apply SQL Transformation 的 SQL 指令輸入在屬性視窗的 SQL Query Script 中即可執行:
https://ithelp.ithome.com.tw/upload/images/20181109/201119357hAPdj00IW.png

【Apply SQL Transformation - SELECT 語法】

Apply SQL Transformation 有 3 個輸入接口,可以輸入 3 個資料集,table 名稱分別為 t1 , t2 , t3

select * from t1;

https://ithelp.ithome.com.tw/upload/images/20181109/20111935RRqD5CYXSA.png

【Apply SQL Transformation - WHERE 語法】

只想要取成人收入資料集中年齡小於 50 的資料,可以使用 where 語法

select * from t1 where age < 50;

https://ithelp.ithome.com.tw/upload/images/20181109/20111935bbPpc7DtGB.png

【Apply SQL Transformation - JOIN 語法】

若想將多個資料集合併,可以使用 join 語法,以下為客戶資料及客戶餐廳評分資料,就可以透過 UserID 將資料合併

  • 【t1】Restaurant Customer data:客戶資料集
  • 【t2】Restaurant Ratings:客戶餐廳評分資料集
select t2.rating,t1.* from t2
left join t1 on t2.UserID=t1.UserID;

https://ithelp.ithome.com.tw/upload/images/20181109/20111935QtLX1iN9MR.png

https://ithelp.ithome.com.tw/upload/images/20181109/201119354MF5Wn1VyU.png

【Apply SQL Transformation - 彙總函數 MAX、MIN、AVG、COUNT、SUM】

若需要統計資料,也可以使用 SQL 的彙總函數,像是 MAX、MIN、AVG、COUNT、SUM,加上條件 GROUP BY 欄位名稱,以下為依據 placeID 計算各個餐廳評分的統計值

  • 【t1】Restaurant Ratings:客戶餐廳評分資料集
  • 【t2】Restaurant Feature data:餐廳資料集
select t1.placeID,t2.name,
max(rating),min(rating),avg(rating),count(rating),sum(rating)
from t1
inner join t2 on t1.placeID=t2.placeID
group by t1.placeID;

https://ithelp.ithome.com.tw/upload/images/20181109/201119359797WZnttM.png

https://ithelp.ithome.com.tw/upload/images/20181109/20111935Ch7dKn54eY.png


上一篇
Azure Machine Learning Studio 文字分析 Preprocess Text
下一篇
Azure Machine Learning Studio 將實驗發佈成 Web Service
系列文
Azure Machine Learning Studio30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言