[{"data":1,"prerenderedAt":1014},["ShallowReactive",2],{"navigation_docs":3,"-machine-learning-decision-tree-vs-deep-learning-on-tabular-data":352,"-machine-learning-decision-tree-vs-deep-learning-on-tabular-data-surround":1009},[4,54,83,116,125,161,179,200],{"title":5,"path":6,"stem":7,"children":8},"Ai","/ai","ai",[9,12,42,46,50],{"title":10,"path":6,"stem":11},"AI 技術探索","ai/index",{"title":13,"path":14,"stem":15,"children":16,"page":41},"Rag","/ai/rag","ai/RAG",[17,21,25,29,33,37],{"title":18,"path":19,"stem":20},"BM25 演算法深入解析：從 TF-IDF 到現代搜尋引擎的核心技術","/ai/rag/bm25-deep-dive-from-tf-idf-to-rag","ai/RAG/bm25-deep-dive-from-tf-idf-to-rag",{"title":22,"path":23,"stem":24},"Dense Retrieval（向量檢索）深入解析","/ai/rag/dense-retrieval-deep-dive","ai/RAG/dense-retrieval-deep-dive",{"title":26,"path":27,"stem":28},"RAG（Retrieval-Augmented Generation）原理與實作入門","/ai/rag/rag-intro-principles-and-implementation","ai/RAG/rag-intro-principles-and-implementation",{"title":30,"path":31,"stem":32},"RAG Retrieval Strategy 深入解析","/ai/rag/rag-retrieval-strategy-deep-dive","ai/RAG/rag-retrieval-strategy-deep-dive",{"title":34,"path":35,"stem":36},"Reciprocal Rank Fusion（RRF）教學：打造更穩定的檢索融合策略","/ai/rag/rrf-reciprocal-rank-fusion-guide","ai/RAG/rrf-reciprocal-rank-fusion-guide",{"title":38,"path":39,"stem":40},"TF-IDF（Term Frequency–Inverse Document Frequency）深入解析","/ai/rag/tf-idf-deep-dive","ai/RAG/tf-idf-deep-dive",false,{"title":43,"path":44,"stem":45},"Docus AI 功能完整實作指南","/ai/docus-ai-implementation","ai/docus-ai-implementation",{"title":47,"path":48,"stem":49},"llms.txt 是什麼？在 Nuxt 中控制 AI 與搜尋引擎爬蟲的新方式","/ai/llms-txt","ai/llms-txt",{"title":51,"path":52,"stem":53},"MCP（Model Context Protocol）是什麼？用「AI 的 USB-C」理解模型如何安全連接工具與資料","/ai/mcp_concept","ai/mcp_concept",{"title":55,"path":56,"stem":57,"children":58,"page":41},"Data Analysis","/data-analysis","data-analysis",[59,63,67,71,75,79],{"title":60,"path":61,"stem":62},"Exploratory Data Analysis（EDA）資料探索分析入門","/data-analysis/exploratory-data-analysis-eda","data-analysis/exploratory-data-analysis-eda",{"title":64,"path":65,"stem":66},"PR-AUC 深入解析：不平衡分類問題的重要評估指標","/data-analysis/pr-auc-for-imbalanced-classification","data-analysis/pr-auc-for-imbalanced-classification",{"title":68,"path":69,"stem":70},"ROC-AUC 深入解析：理解分類模型的判斷能力","/data-analysis/roc-auc-complete-guide","data-analysis/roc-auc-complete-guide",{"title":72,"path":73,"stem":74},"SHAP（SHapley Additive exPlanations）模型解釋方法深入解析","/data-analysis/shap-model-interpretation-complete-guide","data-analysis/shap-model-interpretation-complete-guide",{"title":76,"path":77,"stem":78},"Social Network Analysis（SNA）深入解析","/data-analysis/social-network-analysis-sna","data-analysis/social-network-analysis-sna",{"title":80,"path":81,"stem":82},"Time-based Split：為什麼時間序列資料不能使用 Random Split？","/data-analysis/time-based-split-vs-random-split","data-analysis/time-based-split-vs-random-split",{"title":84,"path":85,"stem":86,"children":87,"page":41},"MachineLearning","/machine_learning","machine_learning",[88,92,96,100,104,108,112],{"title":89,"path":90,"stem":91},"Confusion Matrix（混淆矩陣）完整解析","/machine_learning/confusion-matrix","machine_learning/confusion-matrix",{"title":93,"path":94,"stem":95},"Decision Tree 模型完整教學：從原理到 Python 實作","/machine_learning/decision-tree-complete-guide","machine_learning/decision-tree-complete-guide",{"title":97,"path":98,"stem":99},"為什麼 Decision Tree 在 Tabular Data 上常常勝過 Deep Learning？","/machine_learning/decision-tree-vs-deep-learning-on-tabular-data","machine_learning/decision-tree-vs-deep-learning-on-tabular-data",{"title":101,"path":102,"stem":103},"LightGBM 模型入門：理解高效能的 Gradient Boosting 演算法","/machine_learning/lightgbm-intro-for-tabular-data","machine_learning/lightgbm-intro-for-tabular-data",{"title":105,"path":106,"stem":107},"Logistic Regression（Logit 回歸）完整教學","/machine_learning/logistic-regression-complete-guide","machine_learning/logistic-regression-complete-guide",{"title":109,"path":110,"stem":111},"為什麼模型訓練需要 Train / Validation / Test Dataset？","/machine_learning/train-validation-test-dataset","machine_learning/train-validation-test-dataset",{"title":113,"path":114,"stem":115},"XGBoost 原理與實務教學","/machine_learning/xgboost-complete-guide","machine_learning/xgboost-complete-guide",{"title":117,"path":118,"stem":119,"children":120,"page":41},"Network","/network","network",[121],{"title":122,"path":123,"stem":124},"DNS 設定入門：CNAME vs A Record 完整解析","/network/dns-cname-vs-a-record-guide","network/dns-cname-vs-a-record-guide",{"title":126,"path":127,"stem":128,"children":129},"Nuxt","/nuxt","nuxt",[130,133,137,141,145,149,153,157],{"title":131,"path":127,"stem":132},"Nuxt 實戰指南","nuxt/index",{"title":134,"path":135,"stem":136},"Abstraction Layer 與 Adapter 的差別，一次搞懂設計角色","/nuxt/adapter_abstraction_layer","nuxt/adapter_abstraction_layer",{"title":138,"path":139,"stem":140},"Nuxt 4 全面理解 — 專案檔案結構解析","/nuxt/directory_structure","nuxt/directory_structure",{"title":142,"path":143,"stem":144},"Nuxt 前端 build 流程完整解析","/nuxt/frontend_build","nuxt/frontend_build",{"title":146,"path":147,"stem":148},"Nitro 是什麼？從 Nuxt 專案到 Server 與 Edge 的關鍵引擎","/nuxt/nitro","nuxt/nitro",{"title":150,"path":151,"stem":152},"深入理解 Nuxt 的 .nuxt 與 .output：為什麼部署時一定要分清楚？","/nuxt/nuxt_and_output","nuxt/nuxt_and_output",{"title":154,"path":155,"stem":156},"Nuxt 中 dev、build、preview 的差異一次搞懂","/nuxt/nuxt_dev_build_preview","nuxt/nuxt_dev_build_preview",{"title":158,"path":159,"stem":160},"Nuxt Image vs \u003Cimg>：為什麼 Nuxt 3 專案幾乎都該用 \u003CNuxtImg>？","/nuxt/nuxt_image","nuxt/nuxt_image",{"title":162,"path":163,"stem":164,"children":165},"Python 程式開發","/python","python/index",[166,167,171,175],{"title":162,"path":163,"stem":164},{"title":168,"path":169,"stem":170},"如何在 FastAPI 中調用記憶體 Buffer 回傳圖片 (附實例)","/python/memory_buffer","python/memory_buffer",{"title":172,"path":173,"stem":174},"Python 單元測試教學：如何為你的程式撰寫 Test","/python/python-unit-testing-unittest-pytest","python/python-unit-testing-unittest-pytest",{"title":176,"path":177,"stem":178},"如何使用 uv 取代 pip：改善 Python 專案的開發流程","/python/uv","python/uv",{"title":180,"path":181,"stem":182,"children":183,"page":41},"Statistic","/statistic","statistic",[184,188,192,196],{"title":185,"path":186,"stem":187},"卡方檢定（Chi-Square Test）入門教學","/statistic/chi-square-test-intro","statistic/chi-square-test-intro",{"title":189,"path":190,"stem":191},"常見抽樣方法（Sampling Methods）教學：Stratified、Quota、Convenience、Systematic、Simple Random","/statistic/common-sampling-methods-guide","statistic/common-sampling-methods-guide",{"title":193,"path":194,"stem":195},"Cramér’s V 指標介紹：如何衡量兩個類別變數之間的關聯","/statistic/cramers-v-for-categorical-association","statistic/cramers-v-for-categorical-association",{"title":197,"path":198,"stem":199},"Mann–Whitney U 與 Kolmogorov–Smirnov（KS）檢定：非參數統計檢定的入門指南","/statistic/mann-whitney-u-and-ks-test-intro","statistic/mann-whitney-u-and-ks-test-intro",{"title":201,"path":202,"stem":203,"children":204},"WebDev","/web_dev","web_dev",[205,208,234,248,282,312,334],{"title":206,"path":202,"stem":207},"Web 前端開發","web_dev/index",{"title":209,"path":210,"stem":211,"children":212},"瀏覽器與渲染","/web_dev/browser","web_dev/browser/index",[213,214,218,222,226,230],{"title":209,"path":210,"stem":211},{"title":215,"path":216,"stem":217},"瀏覽器儲存空間完整解析：Cookie、localStorage、IndexedDB 到 Cache Storage","/web_dev/browser/browser-storage-comprehensive-guide","web_dev/browser/browser-storage-comprehensive-guide",{"title":219,"path":220,"stem":221},"DOM (Document Object Model) 深入解析","/web_dev/browser/dom","web_dev/browser/dom",{"title":223,"path":224,"stem":225},"Service Worker Request Flow 深入解析","/web_dev/browser/service-worker-request-flow","web_dev/browser/service-worker-request-flow",{"title":227,"path":228,"stem":229},"CSR、SSR 與 SSG 是什麼？前端渲染策略完整比較","/web_dev/browser/ssr_csr_ssg","web_dev/browser/ssr_csr_ssg",{"title":231,"path":232,"stem":233},"Virtual DOM 深入解析：為什麼它能優化前端效能？","/web_dev/browser/virtual_dom","web_dev/browser/virtual_dom",{"title":235,"path":236,"stem":237,"children":238},"圖形技術","/web_dev/graphics","web_dev/graphics/index",[239,240,244],{"title":235,"path":236,"stem":237},{"title":241,"path":242,"stem":243},"為什麼 Three.js 專案幾乎都選擇 CSR？從 SSR 問題談起","/web_dev/graphics/threejs_csr","web_dev/graphics/threejs_csr",{"title":245,"path":246,"stem":247},"WebGL 是什麼？為什麼前端 3D 幾乎都靠它？","/web_dev/graphics/webgl","web_dev/graphics/webGL",{"title":249,"path":250,"stem":251,"children":252},"架構與配置","/web_dev/infrastructure","web_dev/infrastructure/index",[253,254,258,262,266,270,274,278],{"title":249,"path":250,"stem":251},{"title":255,"path":256,"stem":257},"Zeabur + K3s + Nuxt 部署架構完整解析","/web_dev/infrastructure/k3s-zeabur","web_dev/infrastructure/K3s-zeabur",{"title":259,"path":260,"stem":261},"ECS vs Docker vs Kubernetes：從部署堆疊理解三層架構","/web_dev/infrastructure/ecs-docker-kubernetes-stack","web_dev/infrastructure/ecs-docker-kubernetes-stack",{"title":263,"path":264,"stem":265},"ECS vs VPS 是什麼？從部署網站的角度一次搞懂差別","/web_dev/infrastructure/ecs-vs-vps","web_dev/infrastructure/ecs-vs-vps",{"title":267,"path":268,"stem":269},"Zeabur 內網服務連線完整入門指南","/web_dev/infrastructure/k3s-internal-networking","web_dev/infrastructure/k3s-internal-networking",{"title":271,"path":272,"stem":273},"使用 Microservices 架構設計系統的優勢解析","/web_dev/infrastructure/microservices-architecture-advantages","web_dev/infrastructure/microservices-architecture-advantages",{"title":275,"path":276,"stem":277},"Nginx 入門教學：從反向代理到與 Kubernetes 的架構比較","/web_dev/infrastructure/nginx-intro","web_dev/infrastructure/nginx-intro",{"title":279,"path":280,"stem":281},"YAML 配置是什麼？為什麼現代開發都在用它","/web_dev/infrastructure/yaml-configuration","web_dev/infrastructure/yaml-configuration",{"title":283,"path":284,"stem":285,"children":286},"網絡與通訊","/web_dev/network","web_dev/network/index",[287,288,292,296,300,304,308],{"title":283,"path":284,"stem":285},{"title":289,"path":290,"stem":291},"HTTP Request 結構完整解析：從 Request Line 到 Header 一次看懂","/web_dev/network/http-request-structure","web_dev/network/http-request-structure",{"title":293,"path":294,"stem":295},"OSI 模型（Open Systems Interconnection Model）完整解析","/web_dev/network/osi-model","web_dev/network/osi-model",{"title":297,"path":298,"stem":299},"RESTful API 設計原則與實務解析","/web_dev/network/restful-api","web_dev/network/restful-api",{"title":301,"path":302,"stem":303},"RESTful API 五大設計原則深入解析","/web_dev/network/restful-api-principles","web_dev/network/restful-api-principles",{"title":305,"path":306,"stem":307},"Server-Sent Events (SSE) 深入解析與實作教學","/web_dev/network/sse-introduction","web_dev/network/sse-introduction",{"title":309,"path":310,"stem":311},"WebSocket 入門教學：從概念到 Node.js 實作","/web_dev/network/websocket-introduction","web_dev/network/websocket-introduction",{"title":313,"path":314,"stem":315,"children":316},"認證與安全","/web_dev/security","web_dev/security/index",[317,318,322,326,330],{"title":313,"path":314,"stem":315},{"title":319,"path":320,"stem":321},"使用 Cookie 與 Session 建立使用者驗證（完整新手教學）","/web_dev/security/cookie-session-authentication","web_dev/security/cookie-session-authentication",{"title":323,"path":324,"stem":325},"JWT 驗證機制完整解析：從登入流程到實務應用","/web_dev/security/jwt-authentication","web_dev/security/jwt-authentication",{"title":327,"path":328,"stem":329},"Secret Key 簽名是什麼？從零理解資料簽名的本質","/web_dev/security/secret-key-signing","web_dev/security/secret-key-signing",{"title":331,"path":332,"stem":333},"SSH（Secure Shell）是什麼？從遠端登入到安全通道的核心概念","/web_dev/security/ssh","web_dev/security/ssh",{"title":335,"path":336,"stem":337,"children":338},"SEO 與規範","/web_dev/seo","web_dev/seo/index",[339,340,344,348],{"title":335,"path":336,"stem":337},{"title":341,"path":342,"stem":343},"Canonical URL 是什麼？用生活化方式搞懂前端 SEO 的基本保命符","/web_dev/seo/canonical_link","web_dev/seo/canonical_link",{"title":345,"path":346,"stem":347},"robots.txt 是什麼？SEO 的第一道守門員","/web_dev/seo/robot_txt","web_dev/seo/robot_txt",{"title":349,"path":350,"stem":351},"Nuxt SEO 中的 Meta 與 SEO 工具是如何運作的？","/web_dev/seo/seo","web_dev/seo/seo",{"id":353,"title":97,"body":354,"description":994,"extension":995,"links":996,"meta":997,"navigation":1006,"path":98,"seo":1007,"stem":99,"__hash__":1008},"docs/machine_learning/decision-tree-vs-deep-learning-on-tabular-data.md",{"type":355,"value":356,"toc":981},"minimark",[357,361,370,385,396,399,403,406,463,469,472,483,490,493,552,555,557,561,568,571,577,580,593,600,602,606,612,615,621,627,630,636,639,641,645,651,654,684,687,723,730,732,736,739,751,754,760,767,773,776,787,790,792,796,803,809,812,819,822,828,835,837,841,844,851,857,864,866,870,876,887,893,899,902,916,919,921,925,928,934,937,948,951,953,956,959,971,974,977],[358,359,360],"h2",{"id":360},"從一個常見問題開始",[362,363,364,365,369],"p",{},"在資料科學或機器學習的學習過程中，很多人都會有一個直覺：",[366,367,368],"strong",{},"Deep Learning 應該比其他模型更強","。畢竟在影像辨識、自然語言處理以及語音辨識等領域，深度學習幾乎已經成為主流方法。",[362,371,372,373,376,377,380,381,384],{},"然而在實務上，如果資料型態是 ",[366,374,375],{},"tabular data（表格資料）","，情況往往正好相反。在許多資料科學專案與 Kaggle 競賽中，像是 ",[366,378,379],{},"Decision Tree、XGBoost、LightGBM、CatBoost"," 這類 ",[366,382,383],{},"tree-based model","，常常比深度學習模型表現更好。",[362,386,387,388,391,392,395],{},"要理解這件事情，就需要先了解 ",[366,389,390],{},"tabular data 的特性","，以及 ",[366,393,394],{},"Decision Tree 的運作方式","。",[397,398],"hr",{},[358,400,402],{"id":401},"tabular-data-的結構特性","Tabular Data 的結構特性",[362,404,405],{},"所謂 tabular data，通常指的是以表格形式儲存的資料，每一列是一筆樣本，每一欄是一個特徵（feature）。例如：",[407,408,409,422],"table",{},[410,411,412],"thead",{},[413,414,415,419],"tr",{},[416,417,418],"th",{},"feature",[416,420,421],{},"type",[423,424,425,434,441,449,456],"tbody",{},[413,426,427,431],{},[428,429,430],"td",{},"age",[428,432,433],{},"numerical",[413,435,436,439],{},[428,437,438],{},"income",[428,440,433],{},[413,442,443,446],{},[428,444,445],{},"job",[428,447,448],{},"categorical",[413,450,451,454],{},[428,452,453],{},"country",[428,455,448],{},[413,457,458,461],{},[428,459,460],{},"balance",[428,462,433],{},[362,464,465,466,395],{},"這些特徵之間通常沒有明顯的空間結構或時間結構。與影像、文字或語音資料不同，tabular data 中的欄位彼此往往只是",[366,467,468],{},"描述同一筆資料的不同屬性",[362,470,471],{},"例如在一個簡單的分類問題中，模型可能需要判斷以下條件：",[473,474,480],"pre",{"className":475,"code":477,"language":478,"meta":479},[476],"language-text","income > 50000 AND age \u003C 30\n","text","",[481,482,477],"code",{"__ignoreMap":479},[362,484,485,486,489],{},"這樣的規則其實就是 ",[366,487,488],{},"條件判斷（rule-based interaction）","，而這正是 Decision Tree 非常擅長表達的形式。",[362,491,492],{},"Decision Tree 的決策過程本質上就是一連串的條件判斷，例如：",[473,494,498],{"className":495,"code":496,"language":497,"meta":479,"style":479},"language-python shiki shiki-themes github-dark","if income > 50000:\n    if age \u003C 30:\n        predict = class_A\n","python",[481,499,500,523,540],{"__ignoreMap":479},[501,502,505,509,513,516,520],"span",{"class":503,"line":504},"line",1,[501,506,508],{"class":507},"snl16","if",[501,510,512],{"class":511},"s95oV"," income ",[501,514,515],{"class":507},">",[501,517,519],{"class":518},"sDLfK"," 50000",[501,521,522],{"class":511},":\n",[501,524,526,529,532,535,538],{"class":503,"line":525},2,[501,527,528],{"class":507},"    if",[501,530,531],{"class":511}," age ",[501,533,534],{"class":507},"\u003C",[501,536,537],{"class":518}," 30",[501,539,522],{"class":511},[501,541,543,546,549],{"class":503,"line":542},3,[501,544,545],{"class":511},"        predict ",[501,547,548],{"class":507},"=",[501,550,551],{"class":511}," class_A\n",[362,553,554],{},"這種結構讓 Decision Tree 在處理 tabular data 時，能夠非常自然地表達資料中的邏輯關係。",[397,556],{},[358,558,560],{"id":559},"decision-tree-如何表示決策規則","Decision Tree 如何表示決策規則",[362,562,563,564,567],{},"Decision Tree 透過 ",[366,565,566],{},"節點（node）與分裂條件（split）"," 來逐步將資料切分。每一個節點會選擇一個特徵以及一個閾值（threshold），把資料分成不同的子群。",[362,569,570],{},"例如一棵簡單的決策樹可能長這樣：",[473,572,575],{"className":573,"code":574,"language":478,"meta":479},[476],"income > 50000?\n├─ Yes → age \u003C 30?\n│  ├─ Yes → Class A\n│  └─ No  → Class B\n└─ No  → Class C\n",[481,576,574],{"__ignoreMap":479},[362,578,579],{},"這棵樹的決策流程可以解讀為：",[581,582,583,587,590],"ol",{},[584,585,586],"li",{},"先判斷收入是否大於 50000",[584,588,589],{},"如果是，進一步判斷年齡是否小於 30",[584,591,592],{},"根據不同條件，輸出不同的預測結果",[362,594,595,596,599],{},"因此 ",[366,597,598],{},"Decision Tree 本質上就是一組 if-else 規則的集合","。對於 tabular data 中常見的條件型關係，這樣的模型結構非常合適。",[397,601],{},[358,603,605],{"id":604},"tree-model-非常擅長-feature-interaction","Tree Model 非常擅長 Feature Interaction",[362,607,608,609,395],{},"在許多實際問題中，資料的訊號往往來自 ",[366,610,611],{},"多個特徵之間的交互作用（feature interaction）",[362,613,614],{},"例如在金融詐欺偵測問題中，一筆交易可能只有在同時滿足以下條件時才會被判斷為高風險：",[473,616,619],{"className":617,"code":618,"language":478,"meta":479},[476],"amount > 5000 AND country != home_country AND device_new = True\n",[481,620,618],{"__ignoreMap":479},[362,622,623,624,395],{},"這是一種 ",[366,625,626],{},"非線性且具有條件關係的規則",[362,628,629],{},"Decision Tree 可以透過多層分裂自然地表達這樣的邏輯，例如：",[473,631,634],{"className":632,"code":633,"language":478,"meta":479},[476],"split1: amount > 5000\nsplit2: country != home_country\nsplit3: device_new\n",[481,635,633],{"__ignoreMap":479},[362,637,638],{},"而深度神經網路雖然理論上也能學到這些關係，但通常需要更多資料與更複雜的訓練過程才能學出相同的規則。",[397,640],{},[358,642,644],{"id":643},"tabular-data-的資料量通常有限","Tabular Data 的資料量通常有限",[362,646,647,648,395],{},"另一個重要原因是 ",[366,649,650],{},"資料規模",[362,652,653],{},"深度學習模型通常在資料量極大的情況下才會發揮真正的優勢。例如：",[407,655,656,666],{},[410,657,658],{},[413,659,660,663],{},[416,661,662],{},"dataset",[416,664,665],{},"samples",[423,667,668,676],{},[413,669,670,673],{},[428,671,672],{},"ImageNet",[428,674,675],{},"約 1400 萬張圖片",[413,677,678,681],{},[428,679,680],{},"大型語言模型語料",[428,682,683],{},"數兆 tokens",[362,685,686],{},"相比之下，常見的 tabular dataset 規模通常是：",[407,688,689,697],{},[410,690,691],{},[413,692,693,695],{},[416,694,662],{},[416,696,665],{},[423,698,699,707,715],{},[413,700,701,704],{},[428,702,703],{},"Kaggle 競賽",[428,705,706],{},"10k – 1M",[413,708,709,712],{},[428,710,711],{},"銀行資料",[428,713,714],{},"約 100k",[413,716,717,720],{},[428,718,719],{},"詐欺偵測資料",[428,721,722],{},"約 200k",[362,724,725,726,729],{},"對深度神經網路來說，這樣的資料量其實並不算大，容易出現 ",[366,727,728],{},"overfitting"," 的問題。反之，Decision Tree 與 GBDT 類模型在中小型資料集上通常更穩定。",[397,731],{},[358,733,735],{"id":734},"decision-tree-對-feature-scaling-不敏感","Decision Tree 對 Feature Scaling 不敏感",[362,737,738],{},"在使用深度學習模型時，資料通常需要先進行一些預處理，例如：",[740,741,742,745,748],"ul",{},[584,743,744],{},"normalization",[584,746,747],{},"standardization",[584,749,750],{},"embedding",[362,752,753],{},"例如：",[473,755,758],{"className":756,"code":757,"language":478,"meta":479},[476],"income  → 0 ~ 1\nage     → z-score\nbalance → -1 ~ 1\n",[481,759,757],{"__ignoreMap":479},[362,761,762,763,766],{},"但 Decision Tree 在分裂資料時只會關心",[366,764,765],{},"閾值比較","：",[473,768,771],{"className":769,"code":770,"language":478,"meta":479},[476],"age > 30\nbalance \u003C 1000\n",[481,772,770],{"__ignoreMap":479},[362,774,775],{},"因此：",[740,777,778,781,784],{},[584,779,780],{},"不需要做 scaling",[584,782,783],{},"對 outlier 不太敏感",[584,785,786],{},"對 feature distribution 的要求較低",[362,788,789],{},"這讓 tree-based model 在實務上更容易應用於各種「不完美」的資料。",[397,791],{},[358,793,795],{"id":794},"tree-model-對-categorical-feature-的處理","Tree Model 對 Categorical Feature 的處理",[362,797,798,799,802],{},"Tabular data 中很常包含 ",[366,800,801],{},"類別型特徵（categorical feature）","，例如：",[473,804,807],{"className":805,"code":806,"language":478,"meta":479},[476],"country = {US, TW, JP, CN}\n",[481,808,806],{"__ignoreMap":479},[362,810,811],{},"在神經網路中，這類資料通常需要轉換為：",[740,813,814,817],{},[584,815,816],{},"one-hot encoding",[584,818,750],{},[362,820,821],{},"而 Decision Tree 則可以直接利用類別特徵進行分裂。例如：",[473,823,826],{"className":824,"code":825,"language":478,"meta":479},[476],"country in {US, JP}\n",[481,827,825],{"__ignoreMap":479},[362,829,830,831,834],{},"此外，像 ",[366,832,833],{},"CatBoost"," 這類模型甚至是專門為 categorical feature 設計，能更有效地處理這類資料。",[397,836],{},[358,838,840],{"id":839},"decision-tree-具有天然的-feature-selection","Decision Tree 具有天然的 Feature Selection",[362,842,843],{},"在神經網路中，通常所有特徵都會參與模型計算。",[362,845,846,847,850],{},"但在 Decision Tree 中，模型只會選擇 ",[366,848,849],{},"對預測最有幫助的特徵"," 進行分裂。例如：",[473,852,855],{"className":853,"code":854,"language":478,"meta":479},[476],"split1: income\nsplit2: balance\nsplit3: device_type\n",[481,856,854],{"__ignoreMap":479},[362,858,859,860,863],{},"如果某個特徵沒有提供有用資訊，它可能根本不會出現在樹的任何節點中。這種特性讓 Decision Tree 在面對 ",[366,861,862],{},"高維度或 noisy data"," 時仍然能保持良好的表現。",[397,865],{},[358,867,869],{"id":868},"gbdt多棵樹的集成模型","GBDT：多棵樹的集成模型",[362,871,872,873,395],{},"在實務中，人們通常不只使用一棵 Decision Tree，而是使用 ",[366,874,875],{},"多棵樹的集成模型（ensemble model）",[362,877,878,879,882,883,886],{},"像是 ",[366,880,881],{},"XGBoost"," 或 ",[366,884,885],{},"LightGBM","，其核心概念是：",[473,888,891],{"className":889,"code":890,"language":478,"meta":479},[476],"prediction = tree_1 + tree_2 + tree_3 + ... + tree_n\n",[481,892,890],{"__ignoreMap":479},[362,894,895,896,395],{},"這種方法稱為：",[366,897,898],{},"Gradient Boosting Decision Trees（GBDT）",[362,900,901],{},"GBDT 的優點包括：",[740,903,904,907,910,913],{},[584,905,906],{},"可以學習高度非線性的關係",[584,908,909],{},"能捕捉 feature interaction",[584,911,912],{},"具備良好的正則化能力",[584,914,915],{},"自動進行 feature selection",[362,917,918],{},"因此在 tabular data 的問題上，GBDT 常常能達到非常強的預測效果。",[397,920],{},[358,922,924],{"id":923},"kaggle-競賽中的實戰經驗","Kaggle 競賽中的實戰經驗",[362,926,927],{},"在許多 Kaggle 的 tabular data 競賽中，常見的最佳解法通常是：",[473,929,932],{"className":930,"code":931,"language":478,"meta":479},[476],"LightGBM + XGBoost + CatBoost ensemble\n",[481,933,931],{"__ignoreMap":479},[362,935,936],{},"深度學習模型通常只有在以下情況下才會具有優勢：",[740,938,939,942,945],{},[584,940,941],{},"資料量極大",[584,943,944],{},"特徵結構非常複雜",[584,946,947],{},"需要進行 representation learning",[362,949,950],{},"在大多數傳統表格資料問題中，tree-based model 仍然是最常見且有效的選擇。",[397,952],{},[358,954,955],{"id":955},"結語",[362,957,958],{},"簡單來說：",[740,960,961,966],{},[584,962,963],{},[366,964,965],{},"Deep Learning 擅長學習資料的 representation",[584,967,968],{},[366,969,970],{},"Decision Tree 擅長學習 decision rules",[362,972,973],{},"而 tabular data 中的訊號往往就是各種條件規則與特徵交互作用。因此，在許多實際的資料科學問題中，Decision Tree 與 GBDT 類模型往往會比深度學習模型表現更好。",[362,975,976],{},"理解這些模型與資料結構之間的關係，能幫助我們在不同問題中選擇更合適的機器學習方法。",[978,979,980],"style",{},"html pre.shiki code .snl16, html code.shiki .snl16{--shiki-default:#F97583}html pre.shiki code .s95oV, html code.shiki .s95oV{--shiki-default:#E1E4E8}html pre.shiki code .sDLfK, html code.shiki .sDLfK{--shiki-default:#79B8FF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":479,"searchDepth":525,"depth":525,"links":982},[983,984,985,986,987,988,989,990,991,992,993],{"id":360,"depth":525,"text":360},{"id":401,"depth":525,"text":402},{"id":559,"depth":525,"text":560},{"id":604,"depth":525,"text":605},{"id":643,"depth":525,"text":644},{"id":734,"depth":525,"text":735},{"id":794,"depth":525,"text":795},{"id":839,"depth":525,"text":840},{"id":868,"depth":525,"text":869},{"id":923,"depth":525,"text":924},{"id":955,"depth":525,"text":955},"深入理解 Decision Tree 與 GBDT 在表格資料上的優勢，解析為何在多數資料科學實務中，tree-based model 往往比深度學習模型表現更好。","md",null,{"tags":998,"category":86,"date":1005},[999,1000,1001,1002,1003,1004],"machine learning","decision tree","gbdt","tabular data","xgboost","lightgbm","2026-03-08",true,{"title":97,"description":994},"MlcXeXkj--fzxgHLYVQQRDkFdE977SX52sZZxetXN8I",[1010,1012],{"title":93,"path":94,"stem":95,"description":1011,"children":-1},"深入了解 Decision Tree（決策樹）的運作原理，包含模型結構、純度指標、實際案例與 Python 實作，幫助你掌握最經典的機器學習模型之一。",{"title":101,"path":102,"stem":103,"description":1013,"children":-1},"介紹 LightGBM 的核心概念、運作方式與實際應用，幫助初學者理解為什麼它在表格資料（tabular data）上表現如此優秀。",1776690841760]