ต้นไม้ตัดสินใจและป่าสุ่ม
ตัวจำแนกตามกฎและแบบรวมโมเดล
ต้นไม้ตัดสินใจและป่าสุ่ม เป็นบทเรียน Data Science Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Data Science Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Data Science Academy มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
A Tree of Questions
A decision tree classifies by asking a chain of yes-or-no questions about your features until it reaches an answer. 🌳
Splits at Each Node
Every branch point is a split, a rule like is age above 30. The data flows left or right based on that test.
Leaves Hold the Answer
When no more useful questions remain, you hit a leaf. The class that dominates that leaf becomes the prediction.
Picking the Best Split
A tree chooses each split to make groups as pure as possible, measured by criteria like Gini impurity or entropy.
Easy to Read
One real strength is interpretability: you can follow the path of questions and explain exactly why a prediction was made.
Trees Love to Overfit
Left unchecked, a tree grows deep and memorizes the training data. That overfitting hurts accuracy on new, unseen rows.
Limit the Depth
You tame a tree by capping its growth with max_depth, trading a little training fit for far better generalization.
from sklearn.tree import DecisionTreeClassifier
model = DecisionTreeClassifier(max_depth=4)Many Trees Beat One
A random forest trains many trees and lets them vote. The crowd is far steadier than any single deep tree.
Each Tree Sees Less
For variety, each tree trains on a random sample of rows and a random subset of features. That diversity is the secret sauce.
Build a Forest
It is one line in scikit-learn. Set n_estimators to choose how many trees join the ensemble.
from sklearn.ensemble import RandomForestClassifier
model = RandomForestClassifier(n_estimators=100)Free Feature Importances
A trained forest tells you which inputs mattered most through feature_importances_, a quick guide to what drives predictions.
model.feature_importances_Quick Check
Let's confirm why a forest improves on a single tree.
Recap
A decision tree asks questions down to a leaf; a random forest votes across many trees to cut overfitting. 🎯
คำถามที่พบบ่อย
บทเรียน “ต้นไม้ตัดสินใจและป่าสุ่ม” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “ต้นไม้ตัดสินใจและป่าสุ่ม” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Data Science Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Data Science Academy มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “ต้นไม้ตัดสินใจและป่าสุ่ม”
ตัวจำแนกตามกฎและแบบรวมโมเดล คุณปฏิบัติ Data Science Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Data Science Academy หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Data Science Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน
บทเรียน “ต้นไม้ตัดสินใจและป่าสุ่ม” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Data Science Academy นี้ได้ไหม
ได้ บทเรียน Data Science Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- การถดถอยลอจิสติกสำหรับใช่หรือไม่ใช่
- เพื่อนบ้านใกล้ที่สุด k ตัว
- ต้นไม้ตัดสินใจและป่าสุ่ม
- พื้นฐาน Gradient Boosting