iT邦幫忙

2021 iThome 鐵人賽

DAY 24
0
AI & Data

AI ninja project系列 第 24

AI ninja project [day 24] 決策樹森林 --排名資料

  • 分享至 

  • twitterImage
  •  

隨機決策樹為隨機生成許多決策樹,
利用取袋法來取出選中的決策樹,
而每棵樹的都具有執行結果,
每棵樹依據執行結果來投票,
得票最高的就是最終輸出結果。

https://ithelp.ithome.com.tw/upload/images/20210924/20122678744XvhHlAl.png

而本篇使用的是Gradient Boosting,
利用上一顆樹的執行結果,
將錯誤劃分的個體資訊加以優化,
加強劃分的邊界。

https://ithelp.ithome.com.tw/upload/images/20210924/20122678PGzNcRottI.png
引用圖片參考來源:
https://www.researchgate.net/publication/326379229_Exploring_the_clinical_features_of_narcolepsy_type_1_versus_narcolepsy_type_2_from_European_Narcolepsy_Network_database_with_machine_learning

可以搜尋 Gradient Boosted進行參考。

決策樹森林可以解決分類、迴歸及排名的問題,
今天來介紹解決排名的使用方式。

參考攻略colab:
https://www.tensorflow.org/decision_forests/tutorials/beginner_colab

colab中上部分有分類及迴歸的使用方法,
而我們從訓練排名模型的章節開始:

安裝套件
https://ithelp.ithome.com.tw/upload/images/20210924/20122678rYaf9ZyuAp.png

wurlitzer是幫助把訓練時的日誌資訊詳細的印出,
自己創建模型時,不一定需要這個功能:
https://ithelp.ithome.com.tw/upload/images/20210924/20122678ZGy9R4jTuv.png

載入套件
https://ithelp.ithome.com.tw/upload/images/20210924/20122678XGCtNDhyIc.png

下載排名資料的LETOR3資料集
https://ithelp.ithome.com.tw/upload/images/20210924/20122678MzPX7uK9g7.png

進行清洗並查看資料結構:
https://ithelp.ithome.com.tw/upload/images/20210924/20122678UEmForbkNc.png

可以發現relevance為標籤(label),
0代表越不相關或是越不重要,
而數字越大代表越相關或是重要。
https://ithelp.ithome.com.tw/upload/images/20210924/20122678JC0uwoKQuT.png

切分訓練集及測試集:
https://ithelp.ithome.com.tw/upload/images/20210924/20122678Nk50UxkxtR.png

載入決策樹資料集並且進行訓練:
https://ithelp.ithome.com.tw/upload/images/20210924/20122678yMSPeDEguD.png

那最後我們可以對照預測結果來劃分階級:
https://ithelp.ithome.com.tw/upload/images/20210924/20122678PIAeJ8UZQM.png

https://ithelp.ithome.com.tw/upload/images/20210924/20122678ZgBLjGII3e.png


上一篇
AI ninja project [day 23] 生成對抗網路 Generative Adversarial Network(GAN)
下一篇
AI ninja project [day 25] QLattice -- 基礎分類
系列文
AI ninja project30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言