特徴量の重要度とSHAP
モデルが最も頼りにしたもの
「特徴量の重要度とSHAP」はCoddyKit上の無料Data Science Academyレッスンです。 これはレッスン1/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これは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」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Data Science Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Data Science Academyコースには全4レッスンが含まれています。
「特徴量の重要度とSHAP」で何を学びますか?
モデルが最も頼りにしたもの ブラウザで直接実行するハンズオンコードでData Science Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Data Science Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのData Science Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン1/4です。
「特徴量の重要度とSHAP」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このData Science Academyレッスンでコードを書いて実行できますか?
はい。すべてのData Science Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- 特徴量の重要度とSHAP
- 部分依存の直感的な理解
- 関係者を説得するグラフ
- Notebookからダッシュボードへ