ความสำคัญของคุณลักษณะและ SHAP
สิ่งที่โมเดลใช้เป็นหลัก
ความสำคัญของคุณลักษณะและ SHAP เป็นบทเรียน Data Science Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Data Science Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Data Science Academy มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Which Features Mattered?
After a model trains, you want to know which inputs drove its predictions. That ranking is called feature importance. 🔍
Built-In Tree Importance
Tree models expose a quick feature_importances_ array. Higher values mean the feature was used more often to split the data.
importances = model.feature_importances_Pair It With Names
The importances array is just numbers, so zip it with your column names to read which feature each score belongs to.
import pandas as pd
fi = pd.Series(model.feature_importances_, index=X.columns)Sort to See Top Drivers
Sorting the importance Series surfaces the few features that carry most of the signal in your model.
fi.sort_values(ascending=False).head()The Catch With Trees
Built-in tree scores can favor high-cardinality columns. They tell you usage, not always real impact on predictions.
Permutation Importance
A fairer, model-agnostic method is permutation importance: shuffle one column and measure how much the score drops.
from sklearn.inspection import permutation_importance
r = permutation_importance(model, X_test, y_test)Enter SHAP
For per-prediction detail you use SHAP values, which fairly split each prediction among the features that produced it.
SHAP Is Game Theory
SHAP borrows from game theory: each feature is a player, and its value is the credit it earns toward one specific prediction.
Compute SHAP Values
You build an explainer for your fitted model, then ask it for SHAP values on the rows you care about.
import shap
explainer = shap.Explainer(model)
values = explainer(X_test)Global From Local
Average the absolute SHAP values across all rows and you get a trustworthy global importance ranking, built from local explanations.
shap.plots.bar(values)Explain One Prediction
SHAP also shows why a single row scored as it did, listing which features pushed the prediction up and which pulled it down.
shap.plots.waterfall(values[0])Quick Check
Which method gives a fair, model-agnostic importance score?
Recap
You ranked features with tree, permutation, and SHAP methods, moving from quick scores to fair, per-prediction credit. Next, how one feature moves output. 🎯
คำถามที่พบบ่อย
บทเรียน “ความสำคัญของคุณลักษณะและ SHAP” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “ความสำคัญของคุณลักษณะและ SHAP” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Data Science Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Data Science Academy มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “ความสำคัญของคุณลักษณะและ SHAP”
สิ่งที่โมเดลใช้เป็นหลัก คุณปฏิบัติ Data Science Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Data Science Academy หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Data Science Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน
บทเรียน “ความสำคัญของคุณลักษณะและ SHAP” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Data Science Academy นี้ได้ไหม
ได้ บทเรียน Data Science Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- ความสำคัญของคุณลักษณะและ SHAP
- ทำความเข้าใจ Partial Dependence
- สร้างกราฟที่โน้มน้าวผู้มีส่วนได้ส่วนเสีย
- จากโน้ตบุ๊กสู่แดชบอร์ด